- What programming language are we talking about here?
- What do you mean by "detail on class member object with array"
- Can you share some code (even if it doesn't work) so we can have a better understand if what you're trying to achieve?
If you're trying to add a member to a class that has a type of an array of another class, then you could do something like this:
#include <iostream>
class Detail
{
public:
std::string text;
};
class Person
{
public:
static const size_t detailSize = 5;
Detail details[detailSize];
};
int main()
{
Person person;
person.details[0] = Detail { "Name" };
person.details[1] = Detail { "Age" };
person.details[2] = Detail { "Date of birth" };
person.details[3] = Detail { "Place of birth" };
person.details[4] = Detail { "Address" };
for (int i = 0; i < Person::detailSize; i++)
std::cout << "Detail [" << i << "] : " << person.details[i].text << std::endl;
}
But using std::vector<Detail> would be a better choice than a fixed-size array for many scenarios.