is this a correct array declaration?


I want the array to be a member of a class .....is this correct : string array[12] ??
and let's say I use a constructor to initialize the values then does the constructor need a loop?
I tried creating the array and initializing it without using classes or objects and that was a lot easier for me but I would like to learn to deal with arrays as class members
If you don't do anything the strings default destructor will be used and all the strings will be empty.

In C++11 you can initialize the array elements like this:
1
2
3
4
5
struct Foo
{
	string array[3];
	Foo() : array{"one", "two", "three"} {}
};

In earlier C++ versions you have to set the values in the constructor body.
Last edited on
thanks peter.

ok, so if i'm using an integer or class object data type, then what happens to the constructor initialization for the array when the user inputs the array values?
Last edited on
Topic archived. No new replies allowed.