Generation

generate functionThu, 23 Mar 2023

Inheritance

class Person { public: Person() { cout << "Person()" << endl; } ~Person() { cout << "~Person()" << endl; } void eat() { cout << "Person::eat()" << endl; } protected: int _age; private: int _number; }; class Student : public Person { public: Student() { cout << "Student()" << endl; } ~Student() { cout << "~Student()" << endl; } void eat() { cout << "Student::eat()" << endl; } protected: private: }; void test() { Person *p = new Student; p->eat(); delete p; } int main() { test();

Questions about programming?Chat with your personal AI assistant