最近怎么这么多C++基本问题 期中考要到了?
C++实作了call by value / call by reference / call by address 所以符号比较多
※ 引述《x246libra (宸火)》之铭言:
: class classA
: {
: public:
: int num;
: }
// you forgot ;
;
// the type of aaa is classA
auto aaa = classA();
// the type of bbb is classA&
auto &bbb = aaa;
// the type of ccc is classA*
auto ccc = new classA;
// to use aaa, bbb, ccc
aaa.num = 0;
bbb.num = 1;
(*ccc).num = 2;
// delete to avoid leaking
delete ccc;
因为C++有reference 所以class是value type没错 有&才是reference type
剩下的原文推文有说了 new会在heap 剩下的非static变量会在stack