S
stef
Hello,
Under VS2005 with a console projet:
class Foo
{
private:
static int x;
public:
Foo(int i, int j)
{
cout << "pass number : " << x++ << endl;
}
};
int Foo::x=1;
//-----
void main()
{
vector<Foo> a(10, Foo(5,7));
return;
}
Basically, I suppose that the main vector init will enter ten times
into the constructor of Foo.
Obviously I'm totally wrong, because executing this just gives me only
"pass number: 1" on screen
Conclusion: It seems that vector starts creating only one instance of
the Foo class then "malloc the others"
(9 times in my case)
Why does it do that ? performance ?
Thanks for your help...
Under VS2005 with a console projet:
class Foo
{
private:
static int x;
public:
Foo(int i, int j)
{
cout << "pass number : " << x++ << endl;
}
};
int Foo::x=1;
//-----
void main()
{
vector<Foo> a(10, Foo(5,7));
return;
}
Basically, I suppose that the main vector init will enter ten times
into the constructor of Foo.
Obviously I'm totally wrong, because executing this just gives me only
"pass number: 1" on screen
Conclusion: It seems that vector starts creating only one instance of
the Foo class then "malloc the others"
(9 times in my case)
Why does it do that ? performance ?
Thanks for your help...