菜鸟问题:不能用cin给指针变量赋值??
int *p;
cin > > p; //编译的时候没有问题,但是一运行就出错
这是为什么啊?
[解决办法]
编译也不过的:
error C2679: binary '> > ' : no operator defined which takes a right-hand operand of type 'int * ' (or there is no acceptable conversion)
Error executing cl.exe.
[解决办法]
楼主是不是想这样?
int *p = new(int);
cin > > *p;
.............
delete p;