How to make inheritance C++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
7th Jul 2017, 12:39 PM
Kevin Maruli Sandoval
Kevin Maruli Sandoval - avatar
2 Answers
+ 2
class <class-name>: <visibility-mode> <name of the class from which will be inheritated> visibility-mode: Three types: public, private or protected, which specifies that the inherited data will be public or private or protected in the derived class. Ex. class A { }; class B:public A { //code };
7th Jul 2017, 8:43 PM
Tareq
Tareq - avatar
0
ex. class Myclass { public: void Sayhello () { cout << "hello"; } }; class myclassa: public Myclass { sayhello (); } int main () { myclassa a; a.sayhello ();
9th Jul 2017, 5:34 PM
supercoder
supercoder - avatar