Hi Folks, I have one basic query on constructors and abstract classes.. My query is : why do we require constructor in abstract classes? One reason could be if we have any member variables in abstract classes , to initialize them we can use.. but when that constructor is called , that means an object for that class is created . which implies an object for abstract class is created which according to theroy is error as abstract classes are non instantiable. Please pull me out from this confusion.. Code exm: // Constructor$AbsCls.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<stdio.h> #include<iostream> using namespace std; class abscls { public: int x; abscls() { x = 30; cout<<"I m in constructor "<<endl; } virtual void show()=0; }; class absclsder:public abscls { public: int y; absclsder() { cout<<"I m in abstract class der cls"<<endl; } void show() { cout<<"I m in show of der"<<endl; } }; int _tmain(int argc, _TCHAR* argv[]) { class absclsder obj; return 0; } Thx, --Gopi
Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ [Non-text portions of this message have been removed]