array of objects

How do I declare an array of objects from same class,sending different arguments for each object? In which case do I need to allocate each one of the objects before using them?If possible, provide me an example. Thanks
you can use this syntax:
Type array [] = { Type(argument for 1st), Type(argument for 2nd) , ... };
Thanks!!Anoher question: I will have to send this array to another class(Type2 if you want)and produce a pointer array to this array(**Type). I am a little bit confused about when using dynamic memory allocation. I will use **type to print the array
Do you mean something like this?
1
2
3
4
5
6
7
8
Type array [] = {/*some values*/};

struct Type2
{
    Type **otherArray;
} obj2;
obj2.otherArray = new Type*[/*a number*/];//dynamically create an array of pointers
obj2.otherArray[0] = array;//make the 1st pointer pointing the same position of 'array' 


To print the array elements you would need a loop
eg:
1
2
3
4
5
for ( unsigned i = 0; i < arraySize; i++ )
{
    cout << array[i] << ' '; // if using array
    cout << obj2.otherArray[0][i] << ' ';//if using the array of pointers
}
Thanks for the help
Topic archived. No new replies allowed.