ch11_1b.cpp

来自「Since the field of object oriented progr」· C++ 代码 · 共 96 行

CPP
96
字号
                             // Chapter 10 - Programming exercise 1
#include "ch11-1a.h"         // This is SUPERVSR.H
#include <iostream.h>

// In all cases, init_data assigns values to the class variables and
//  display outputs the values to the monitor for inspection.

void
supervisor::init_data(char in_name[], int in_salary, char in_title[])
{
   strcpy(name,in_name);
   salary = in_salary;
   strcpy(title, in_title);
}




void
supervisor::display(void)
{
   cout << "Supervisor --> " << name << "'s salary is " << salary <<
                                 " and is the " << title << ".\n\n";
}




void
programmer::init_data(char in_name[], int in_salary, char in_title[],
                  char in_language[])
{
   strcpy(name,in_name);
   salary = in_salary;
   strcpy(title, in_title);
   strcpy(language, in_language);
}




void
programmer::display(void)
{
   cout << "Programmer --> " << name << "'s salary is " << salary <<
                                        " and is " << title << ".\n";
   cout << "               " << name << "'s specialty is " << 
                                                 language << ".\n\n";
}




void
secretary::init_data(char in_name[], int in_salary, 
                             char in_shorthand, char in_typing_speed)
{
   strcpy(name,in_name);
   salary = in_salary;
   shorthand = in_shorthand;
   typing_speed = in_typing_speed;
}




void
secretary::display(void)
{
   cout << "Secretary ---> " << name << "'s salary is " << salary <<
                                                                 ".\n";
   cout << "               " << name << " types " << typing_speed <<
              " per minute and can ";
   if (!shorthand) cout << "not ";
   cout << "take shorthand.\n\n";



void
consultant::init_data(char in_name[], int in_salary, char in_title[])
{
   strcpy(name,in_name);
   salary = in_salary;
   strcpy(title, in_title);
}




void
consultant::display(void)
{
   cout << "Consultant --> " << name << "'s salary is " << salary <<
                                 " and is the " << title << ".\n\n";
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?