我正在學習引用和指針,並且本教程中的某些內容沒有爲我編譯(我正在使用GCC)。變量引用
好,這裏是代碼:
#include <iostream>
using namespace std;
int main()
{
int ted = 5;
int andy = 6;
ted = &andy;
cout << "ted: " << ted << endl;
cout << "andy: " << andy << endl;
}
編譯器輸出的說「錯誤:從‘詮釋*’到‘廉政’無效轉換」 我也嘗試了串= V; v = &andy;但這也沒有效果。
如何將內存地址分配給變量?
要非常小心談論引用,當你的意思是指針。 – Matt 2012-03-25 20:50:38
當你指的是指針時,在談論內存地址時也要非常小心。 – Pubby 2012-03-25 20:53:32