create class with array
I need to create an array of classes inside an other class.
Here you go:
class Class {};
class OtherClass {
Class array[1];
};
you should look at using std::vector, instead of carring about C-style arrays.
This is more the C++ way of coding, imagine a class containing an array of double:
class A
{
public:
std::vector<double> m_doubles;
}
EDIT: so for an array of class, let's say class B:
class A
{
public:
std::vector<B> m_bs;
}
EDIT2:
and like @cppanda suggests in the comments below, the implementation of std::vector is done in the Standard C++ Library (also known as the STL). It's really worth the effort learning to use it intensively, a lot of things already done for you. ( like vector and many sorts of containers)
Have you created a class and arrays before? Here is some info. If you want to know something about arrays: here
精彩评论