Animal *arr = new Animal[counter];
Foo(*arr);
void Foo (Animal &arr) {
cout << arr[3].x; // Тут ошибка
}
void Foo (Animal &arr)
class Animal {
public:
std::string Name;
};
void Foo(Animal *arr) {
cout << arr[1].Name.c_str() << endl;
}
void main()
{
Animal *animals = new Animal[3];
animals[0].Name = "Cat";
animals[1].Name = "Dog";
animals[2].Name = "Cow";
Foo(animals);
animals[1].Name = "Change to Dog";
Foo(animals);
}