Zulfi Khan2
March 25th, 2002, 03:00 AM
I have a class containing two data members & I have created & array of object but I am not able to initialize this array with constructor.
Can some body plz help me?
#include "iostream.h"
class test{
int a;
int b;
public:
test(int ar1,int ar2){
a=ar1;
b=ar2;
}
void show(){
cout<<"a="<<a;
cout<<"b="<<b;
}
};
main() {
test obj[2]={{2,3},{2,3}};
obj[0].show();
obj[1].show();
}
Can some body plz help me?
#include "iostream.h"
class test{
int a;
int b;
public:
test(int ar1,int ar2){
a=ar1;
b=ar2;
}
void show(){
cout<<"a="<<a;
cout<<"b="<<b;
}
};
main() {
test obj[2]={{2,3},{2,3}};
obj[0].show();
obj[1].show();
}