An Array of Classes

This is a discussion on An Array of Classes within the C++ Programming forums, part of the General Programming Boards category; I need to create an array of classes; something like; I have a class named calculate, and I need to ...

Code\

In the furture please use Code Tags. They make your code MUCH easier to read and people will be much more likely to help you if you do. And they'll be happy about helping you

For example:

Without code tags:

for(int i=0;i<5;i++)
{
cout << "No code tags are bad";
}

With Code Tags:

Code:

for(int i=0;i<5;i++)
{
cout << "This code is easy to read";
}

This is of course a basic example...more complicated code is even easier to read with code tags than without.

I've added code tags for you this time. They can be added by putting [ code ] at the beginning of your code and [ /code ] at the end, only without the spaces. More information on code tags may be found at the link on my signature.

but there are several techincal hitches. First an array of any size at all, particularly if the objects are of any significant size, will eat up your stack space, so it may be best to use the free store instead. Second, the compiler will use the default constructor when creating each calculations declared in the array, so you have to have a default constructor available--either by using the default default constructor the compiler will provide if you don't declare any other constructors, or, preferably by declaring and implementing your own default constructor.

sounds like you were filling up the variable stack with the array of size 1000. If you want to use that size of an array, then you will need to reset the size of the variable stack, or more commonly, use the free store/heap/dynamic memory to store all the variables.