In the first post the problem was that m_speed is not public also u should access m_speed using Scope resolution operator as m_speed is not a member of B. class A { public: virtual int speed()=0; int m_speed; }; class B:public A { public: int speed() { return A::m_speed; } }; For ur second question...
int main() { A *aptr=new B; cout<<aptr->speed(); return 0; } I hope ur not clear with the concept of virtual functions... This example will help you. If not post back ur questions... -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.