?? 06p2.cpp
字號:
/*
NIIT 《C++ & CGI PROGRAMMING &SCRRIPTING》 Skill Base
教材P6.9 6.P.2
審核:周永 Laozhou@swpi.edu.cn 23:30 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()
{
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()
{
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()
{
cout << endl << endl << "ENTER CUSTOMER'S DETAILS";
Person::accept();
cout << endl << "Customer's billing address: ";
cin.getline(billingAddress, 50);
cout << endl << "Amount due: ";
cin >> amountOutstanding;
}
void display()
{
cout << endl << endl << "CUSTOMER'S DETAILS ";
Person::display();
cout << endl << "Billing address : " << billingAddress;
cout << endl << "Outstanding amount: " << amountOutstanding << endl;
}
};
class Dealer : public Person
{
private:
char shopAddress[51];
int numSold;
public:
void accept()
{
cout << endl << endl << "ENTER DEALER'S DETAILS";
Person::accept();
cout << endl << "Shop address : ";
cin.getline(shopAddress, 50);
cout << endl << "Number Sold : ";
cin >> numSold;
}
void display()
{
cout << endl << endl << "DEALER'S DETAILS ";
Person::display();
cout << endl << "Shop address : "
<< shopAddress;
cout << endl << "Number sold : "
<< numSold << endl;
}
};
int main()
{
Customer custobj;
custobj.accept();
custobj.display();
Dealer dealerobj;
dealerobj.accept();
dealerobj.display();
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -