I'm trying to store the value of an address in a non pointer int variable, when I try to convert it I get the compile error "invalid conversion from 'int*' to 'int'" this is the code I'm using:
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
vector<int> test;
int main() {
int *ip;
int pointervalue = 50;
int thatvalue = 1;
ip = &pointervalue;
thatvalue = ip;
cout << ip << endl;
test.push_back(thatvalue);
cout << test[0] << endl;
return 0;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…