P
Peskov Dmitry
class simple_class
{
int data;
public:
simple_class() {data=10;};
simple_class(int val) : data(val){}
};
int main()
{
simple_class obj1(10); // Initializing a single object through
single parameter constructor
return 0;
}
How to initialize the values of array of simple_class objects during
declaration through the single paramter constructor?
1 method i know is
simple_class obj_array[]={5,6,10};
However, I would like to know if there is any alternative way so that
i can initialize things while declaring an array of objects ?
{
int data;
public:
simple_class() {data=10;};
simple_class(int val) : data(val){}
};
int main()
{
simple_class obj1(10); // Initializing a single object through
single parameter constructor
return 0;
}
How to initialize the values of array of simple_class objects during
declaration through the single paramter constructor?
1 method i know is
simple_class obj_array[]={5,6,10};
However, I would like to know if there is any alternative way so that
i can initialize things while declaring an array of objects ?