Explain step by step, please help😊 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Explain step by step, please help😊

#include <iostream> using namespace std; class Mother { public: Mother() {}; void sayHi() { cout << "Hi"; } }; class Daughter: public Mother { public: Daughter() {}; }; int main() { Daughter d; d.sayHi(); }

15th Feb 2020, 9:03 PM
Hussein Ashammeri
Hussein Ashammeri - avatar
1 Answer
+ 2
class Mother is the base class witch contains a method sayHi. class Daughter is a class that inherrits from class Mother so it has access to the method sayHi. d is an instance of the class Daughter so we can call the method sayHi
15th Feb 2020, 9:09 PM
Gabriel Ilie
Gabriel Ilie - avatar