#include <iostream>
#include <vector>
using namespace std;
class Foo {
public:
Foo() {
cout << "Foo constructor" << endl;
}
Foo(const Foo&) {
cout << "Foo copy constructor" << endl;
}
Foo& operator= (const Foo&) {
cout << "Foo operator =" << endl;
return *this;
}
~Foo() {
cout << "Foo destructor" << endl;
}
};
int f(Foo) {
return 0;
}
int g(const Foo&) {
return 0;
}
Foo h() {
Foo foo;
return foo;
}
int main(void) {
int i=1;
cout<<i++<<endl;
Foo vf1;
cout<<i++<<endl;
f(vf1);
cout<<i++<<endl;
g(vf1);
cout<<i++<<endl;
Foo vf2 = vf1;
cout<<i++<<endl;
vf2 = h();
cout<<i++<<endl;
Foo *pf = new Foo();
cout<<i++<<endl;
delete pf;
cout<<i++<<endl;
vector<Foo> vecf(3);
cout<<i++<<endl;
return 0;
}
#include <vector>
using namespace std;
class Foo {
public:
Foo() {
cout << "Foo constructor" << endl;
}
Foo(const Foo&) {
cout << "Foo copy constructor" << endl;
}
Foo& operator= (const Foo&) {
cout << "Foo operator =" << endl;
return *this;
}
~Foo() {
cout << "Foo destructor" << endl;
}
};
int f(Foo) {
return 0;
}
int g(const Foo&) {
return 0;
}
Foo h() {
Foo foo;
return foo;
}
int main(void) {
int i=1;
cout<<i++<<endl;
Foo vf1;
cout<<i++<<endl;
f(vf1);
cout<<i++<<endl;
g(vf1);
cout<<i++<<endl;
Foo vf2 = vf1;
cout<<i++<<endl;
vf2 = h();
cout<<i++<<endl;
Foo *pf = new Foo();
cout<<i++<<endl;
delete pf;
cout<<i++<<endl;
vector<Foo> vecf(3);
cout<<i++<<endl;
return 0;
}