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

📄 06p1.cpp

📁 C++ interview materials. Very helpful for interview. Including Answer.
💻 CPP
字号:
/*
NIIT 《C++ & CGI PROGRAMMING &SCRRIPTING》 Skill Base
教材P6.7	6.P.1
审核:周永 Laozhou@swpi.edu.cn	23:28 2004-10-18
测试环境:Microsoft Windowsn 2000(VC++);Red Hat Linux 7.3;Red Hat Linux 9.0
*/

#include <iostream>
using namespace std;
class Person
{
public:
	char name[26];
	char dateOfBirth[11];
	char city[26];
	char mobileNo[11];
	char phoneNo[11];
	void accept_Person()
	{
		cout << endl << "Name: ";
		cin.getline(name, 25);
		cout << endl << "Date of Birth: ";
		cin >> dateOfBirth;
		cin.ignore();
		cout << endl << "City: ";
		cin.getline(city, 25);
		cout << endl << "Mobile phone number: ";
		cin >> mobileNo;
		cin.ignore();
		cout << endl << "Residence phone number: ";
		cin >> phoneNo;
		cin.ignore();
     }
	void display_Person()	
	{
		cout << endl << "Name             : " << name;
		cout << endl << "Date of birth    : " << dateOfBirth;
		cout << endl << "City             : " << city;
		cout << endl << "Mobile number    : " << mobileNo;
		cout << endl << "Residence number : " << phoneNo;
      	cin.ignore();
	}
};


class Customer : public Person
{
private:
     char billingAddress[51];
     float amountOutstanding;
public:
	void accept_Customer()
	{
		cout << endl << endl << "ENTER CUSTOMER'S DETAILS";
		accept_Person();
		cout << endl << "Customer's billing address: ";
		cin.getline(billingAddress, 50);
		cout << endl << "Amount due: ";
		cin >> amountOutstanding;
	}

	void display_Customer()
	{
		cout << endl << endl << "CUSTOMER'S DETAILS ";
		display_Person();
		cout << endl << "Billing address   : " << billingAddress;
		cout << endl << "Outstanding amount: "   << amountOutstanding << endl;
	}
};

class Dealer : public Person
{
private:
     char shopAddress[51];
     int numSold;
public:
	void accept_Dealer()
	{
           cout << endl << endl << "ENTER DEALER'S DETAILS";
           accept_Person();
           cout << endl << "Shop address      : ";
           cin.getline(shopAddress, 50);
           cout << endl << "Number Sold       : ";
           cin >> numSold;
	}
	void display_Dealer()
	{
           cout << endl << endl << "DEALER'S DETAILS ";
           display_Person();
           cout << endl << "Shop address      : " 
                << shopAddress;
           cout << endl << "Number sold       : " 
                << numSold << endl;
	}
};


int main()
{
      Customer custobj;
	custobj.accept_Customer();
	custobj.display_Customer();
      Dealer dealerobj;
	dealerobj.accept_Dealer();
	dealerobj.display_Dealer();
      return 0;
}

⌨️ 快捷键说明

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