Re: [閒聊] pointer 指位器是什麼

作者: Euphokumiko (上低音號)   2018-09-17 20:02:52
指標喔
就是某個東西的記憶體位置
比如說我宣告一個整數
int a = 10;
然後我另外宣告一個整數的指標
int *b = &a;
上面的步驟可以理解成
int *b;
b = &a;
宣告一個整數指標
然後把變數a的記憶體位置指派進去
然後你要輸出的時候
cout << b;
這樣會直接輸出記憶體位置
像是009EF920之類的
cout << *b;
這樣才會輸出10
大概是這樣
阿假設今天有個class叫做mumi
你可以用
mumi *idiot;
idiot = new mumi(constructor);
之類的
"因該"是這樣啦
過了個暑假差不多忘光光了
作者: Karlsland (Erica)   2018-09-17 20:05:00
應啦幹
作者: qxxrbull (XPEC)   2018-09-17 20:06:00
星ptr

Links booklink

Contact Us: admin [ a t ] ucptt.com