constructor invocation---other than the defaults?
Code:
class myclass
{
int i,j;
public:
myclass():i(0){}
myclass(int a):i(a),j(a){}
myclass(int a,int b):i(a),j(b){}
void put()
{
cout<<i<<" "<<j<<endl;
}
};
main()
{
myclass *obj=new myclass[5];
}
This works out well for def constructors. if i need the the other two constructors to be invoked what must be done here? Please help.
for an array object any ctor could be invoked?Right!!
if it is an arrayObject then the constructor could be invoked like
Code:
myclass m[5]={1,2,3,4,5}
for the second ctor, right? Can't it happen for an pointer then!!Help me.