HELP!!!!!!!!!!!!!!!!C++? NEW HAND!!!!!!!!

2007-03-03 4:48 pm
Would any body tell me how to define the class and sub class in C++?
And the example, also.Please.
Thank!!!!!!

回答 (1)

2007-03-04 12:09 am
✔ 最佳答案
class parent {
public:
parent();
parent(int num);
void parentMethod1();
virtual void parentMethod2();
~parent();
private:
int x;
};

class child : public parent {
public:
child();
~child();
void parentMethod2();
private:
(...etc...)
};

C++係Object-oriented language, 用sub-class inherit parent既function可以响parent method加virtual. 好似parentMethod2咁. 詳細請看definition of polymorphism.


收錄日期: 2021-04-23 21:04:47
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070303000051KK00665

檢視 Wayback Machine 備份