-
Concrete Method (Normal Method)
- Fully defined inside the class.
Copyclass A { public: void display() { cout << "Hello" << endl; } // normal method }; -
Virtual Method
- Declared with
virtual, can be overridden in derived classes.
Copyclass A { public: virtual void show() { cout << "A’s show" << endl; } }; - Declared with
-
Pure Virtual Method (Abstract Method)
-
Declared with
= 0, has no body in the base class. -
Must be implemented in the derived class.
Copyclass A { public: virtual void draw() = 0; // pure virtual (abstract method) }; -
Methods in C++
In C++, a method is just a function inside a class. There are different types of methods depending on whether they are implemented or not:
Updated on