参照
class CPYCost {
public:
CPYCost();
~CPYCost();
CPYCost& operator=(const CPYCost& rhs);
int x;
private:
};
void refAdd(int &x);
void pAdd(int *x);
void refUse() {
int x = 1;
int& r = x;
r = 2;
int z = 1;
int* p = &z;
*p = 2;
int t = 10;
refAdd(t);
pAdd(&t);
CPYCost *c = new CPYCost();
c->x = 1000;
CPYCost d;
d.x = 2500;
CPYCost &dd = d;
CPYCost ddd = d;
std::cout << ddd.x << std::endl;
}
void refAdd(int &x) {
x++;
}
void pAdd(int *x) {
(*x)++;
}
void lambdaUse() {
auto l = [](int x)->int {
return x+3;
};
int x = l(5);
auto l2 = [x](int a)->int {
return x+10;
};
auto l4 = [=](int a)->int {
return x+10;
};
std::cout << x << std::endl;
}