0
I don’t understand why when I create a copy constructor and push back on a vector, it calls the constructor more than once!
If I do only 1 push back, it will show 1 time the copy builder. if I do 2 push back increases to 3.
I would also like to know why I cannot use && in! foo(foo&& p){}
#include <iostream>
#include <vector>
using namespace std;
class foo {
public :
foo(const foo& p){
cout<<"Construtor de Copia"<<endl;
}
foo () {
cout << "Chamando o Construtor " << endl ;
}
~ foo () {
cout << "Chamando o Destrutor " << endl ;
}
};
int main ( int argc , const char * argv []) {
vector < foo > v3 ;
foo f1;
v3.push_back(f1);
v3.push_back(f1);
return 0;
}