void show();
void show()const; };
void PP::show() {
cout< void PP::show() const { cout< int main() { PP p1('F'),p2; const PP p3('N'); p1.show(); p2.show(); p3.show(); cout< н£ F@U@N! Press any key to continue ԭ show()ذ汾p1.show()p2.show()õΪͨ͵void PP::show()p3.show();õvoid show()const;Ϊp3ʱ䶨Ϊ˳ 4днԱdouble Area()const ȥconst Ϊʲô #include const double PI; double r; public: Circle(double rr):PI(3.14) { r=rr; } double Area()const { return PI*r*r; } }; int main() { Circle c1(4); const Circle c2(5); cout< нΪ 50.24 78.5 Press any key to continue ԭ ʾΪ 'Area' : cannot convert 'this' pointer from 'const class Circle' to 'class Circle &' Ϊc2ΪйóԱɾdouble Area()constеconstʧȥԱʹcout< 1 һʦteacher»Ա (1)˽ݳԱ ʦţ string id string name רҵ string speciality 2˽о̬ݳԱ ̹static int count 3гԱ 캯Ĺ캯 teacherstringstringstring Ĺ캯 teacher 캯Ӧʵÿδʦʱcount+1 ~ teacherӦʵÿνʦʱcount-1 void Printconst ȡ̬ݳԱstatic intGetcount Ķ弰н£Ķ弰иʵִ룬 һij int main(int argc, char* argv[]) { teacher *Teachers[MOSTCOUNT]; int Teacher_count=0; string id_tmp; string name_tmp; string speciality_tmp; while(Teacher_count < MOSTCOUNT) { // cout << \ʦϢԽ\cout << \cin >> id_tmp; cout << \cin >> name_tmp; cout << \cin >> speciality_tmp; //ʦ Teachers[Teacher_count]=new teacher(id_tmp,name_tmp,speciality_tmp); //ڵĶϢ cout << \Ѵʦ\<< \ʦϢ£\for(int i=0;i<=Teacher_count;i++) { (Teachers[i])->Print(); } //Ƿɾһ int del_flag=0; cout << \Ƿɾʦ1 ǣ0 \cin >> del_flag; if(del_flag) { delete Teachers[Teacher_count]; } else { Teacher_count++; } } return 0; } н£ id:1 name:piter speciality:teacher Ѵʦ1 ʦϢ£ Teacher's info:(id):1(name):piter(speciality):teacher Ƿɾʦ1 ǣ0 0 ʦϢԽ id:2 name:bob speciality:peteacher Ѵʦ2 ʦϢ£ Teacher's info:(id):1(name):piter(speciality):teacher Teacher's info:(id):2(name):bob(speciality):peteacher Ƿɾʦ1 ǣ0 1 ʦϢԽ id:3 name:july speciality:ssteacher Ѵʦ2 ʦϢ£ Teacher's info:(id):1(name):piter(speciality):teacher Teacher's info:(id):3(name):july(speciality):ssteacher Ƿɾʦ1 ǣ0 : #include #define MOSTCOUNT 5 using namespace std; class teacher { private: string id; string name; string speciality; static int count; public: teacher(string i,string n,string s); teacher(); ~teacher(); void Print() const; static int Getcount(); }; int teacher::count=0; teacher::teacher() { count++; } teacher::~teacher() { count--;