Hey Guys(and Girls)
have hit a snag with a manager i'm writing
if you create a basic class such as
class Foo{
private:
public:
Foo(int input);
int Bar;
}
Foo::Foo(int input){
Bar = Input;
}
and create an array of them on the heap
Foo* m_FooArray = new Foo[100];
can you initialise them all with the same non standard constructor?
something like this(but this particular syntax doesnt work)
Foo* m_FooArray = new Foo[100](27);
i've found it possible to get the same thing done other ways ie:
add a default constructor and a function to do the same thing as the constructor,then cycle through each entry and use that function:
like so
class Foo{
private:
public:
BarInit(i);
int Bar;
}
Foo::BarInit(int input){
Bar = Input;
}
Foo* m_FooArray = new Foo[100];
for(int i = 0;i<256;i++){
Foo->BarInit(27);
}
but it just seems so inelegant
Thank you in advance for any help
ps: if the same thing can be done with std::vector i am open to that as well