[問題] const pointer
class Student
{
public:
void Read(){}
};
const Student *pStu1 = new Student;
Student const *pStu2 = new Student;
pStu1->Read();// error
pStu2->Read();// error
以上是程式碼
小弟目前知道pStu1與pStu2的宣告其實是一樣
但不了解為何一樣
其二
為什麼無法呼叫其成員函式Read()?
錯誤訊息:
無法將 'this' 指標從 'const Student' 轉換成 'Student &'
煩請各位板友提點一下~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 112.104.97.176
※ 編輯: NIKE74731 來自: 112.104.97.176 (11/02 22:40)
→
11/02 22:51, , 1F
11/02 22:51, 1F
※ 編輯: NIKE74731 來自: 112.104.97.176 (11/02 22:55)
→
11/02 22:55, , 2F
11/02 22:55, 2F
推
11/02 22:57, , 3F
11/02 22:57, 3F
→
11/02 22:58, , 4F
11/02 22:58, 4F
→
11/02 22:59, , 5F
11/02 22:59, 5F
→
11/02 22:59, , 6F
11/02 22:59, 6F
→
11/02 23:01, , 7F
11/02 23:01, 7F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章