Afficher un message
Vieux 30/06/2008, 19h03   #1
Peskov Dmitry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Initializing array of objects during declaration

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 ?
  Réponse avec citation
 
Page generated in 0,05113 seconds with 9 queries