⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch11_1b.cpp

📁 Since the field of object oriented programming is probably new to you, you will find that there is a
💻 CPP
字号:
                             // 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -