I got this code online but I am having problem understanding it:
From my previous understanding of inheritance function defined by Line 1 is redundant.Code:#include <iostream> #include <algorithm> #include <vector> #include <fstream> using namespace std; class Parent { public: virtual void action( const char how ) //....Line 1 { this->action( &how ); } virtual void action( const char * how ) = 0; }; class Son : public Parent { public: using Parent::action; //....Line 2 void action( const char * how ) { cout<<"Action:"<<*how<<endl; } }; int main() { Son s; s.action( 'a' ); system("pause"); return 0; }
(1) Why do we need it, since if I delete it, there is an error?
(2) Why do we need the Line 2?
I have walked through the debugger but I do not understand the logic of code.




Reply With Quote