#include <iostream>
using namespace std;
void reference(int &ref){
cout << ref << endl;
}
void pointer(int *ref){
cout << *ref << endl;
}
int main(){
int *i = new int[1];
*i = 10;
reference(*i); // fine
reference(i); // why not compiling!!! why not referencing to my pointer??
pointer(i); // fine
}
포인터를 참조하고 싶습니다. 포인터는 아니지만 값을 참조 할 수 있습니다. 아닌``int` 변수를 -포인터를 참조 할 수없는 이유는 무엇입니까?
reference(i);
다음과 같이 할 수 있습니다.'void pointer (int * & ref) {'. 당신이 실제로 무엇을 요구하고 있는지 약간 불분명합니다. –
크래시가 발생하지 않습니다. 컴파일 오류입니다. –
그러나 왜 투표가 내려 졌는지, 유효한 질문 인 것 같습니까 ?? –