- #1
sameergk
- 4
- 0
consider the program
Class A
{
int a;
public:
A(int m = 0)
{
a = m;
}
}
int main()
{
int i = 0;
/* Intansiate/Initilize Object with the Constructor */
A Object(0);
/* Here is the Problem */
/* Create the 32 Objects of Class A */
A nObjects[32]; /* ... How to instantiate here for the array of objects?? */
}
Now if i want to initialize the nObjects.a = i during the constructor call;
How do i achieve that?
Here i get a compiler error stating no constructor match found for nObjects.
Class A
{
int a;
public:
A(int m = 0)
{
a = m;
}
}
int main()
{
int i = 0;
/* Intansiate/Initilize Object with the Constructor */
A Object(0);
/* Here is the Problem */
/* Create the 32 Objects of Class A */
A nObjects[32]; /* ... How to instantiate here for the array of objects?? */
}
Now if i want to initialize the nObjects.a = i during the constructor call;
How do i achieve that?
Here i get a compiler error stating no constructor match found for nObjects.