For this diagram:
http://chorist.mis.ccu.edu.tw/teachi...al/final_5.jpg
Let's talk about the class "S" and "T" only.
Should I write like this:
or this ?Code:class S{ public: void setID(); int getID(); void printID(); private: int i ; }; class T : public S{ protected: int j; };
The 'i' and 'j' are not important.Code:class S{ public: void setID(); int getID(); void printID(); private: int i ; }; class T : public S{ public: void setID(); // <<< different at here int getID(); void printID(); protected: int j; };
The main point is whether I should write the functions repeatedly in the inheritance.
My teacher give me the model answer like the second form. I am wondering because I believe that the first form is correct.
thx.
ref:
'+' = public
'-' = private
'#' = protected