如果您从同一类的main中调用了三个对象,如下所示:
customer one(856756, "New York");
customer two(896557, "New York");
customer three(896571, "Washington");
当您上这样的课程时,如何打印出具有相同城市的人的列表:
class customer {
public:
customer(int RegNr, string City) { this->RegNr = RegNr; this->City = City; }
customer(){}
~customer() { cout << "Customer with registration number " << RegNr << " has been destroyed." << endl; }
void setRegNr(int RegNr){this->RegNr=RegNr;}
void setCity(int City) { this->City; }
string getCity() const { return City; }
int getRegNr() const { return RegNr; }
private:
int RegNr;
string City;
};