I wrote the following code.
#include <iostream> using namespace std; class CI { public: virtual void display() =0; }; class Inter: public CI { public: int parseData (int); }; Inter::parseData (int data) { cout <<"Parsing the data "<<data; return data*100; } class Last: public Inter { public: void display(); }; void Last::display() { cout <<" Last:: Displaying From Last "<<endl; } class USB: public Inter { public: void display(); }; void USB::display() { cout <<" USB:: Displaying From Last "<<endl; } int main ( int argc, char ** argv) { int temp; CI *obj = new Last; obj->display(); temp = obj->parseData (100); cout <<"Parsed DAta .. "<<temp<<endl; delete obj; obj = new USB; obj->display(); temp = obj->parseData (200); }
My question is:
Why can't I call the obj-> parseData function ?. In my understanding, Therefore, the class "Last" and "USB" comes from the class "Inter", should it be right to be called? ..
Tell me, where is my understanding wrong?
source share