# include <iostream>
int main()
{
using std::cout;
int *p= new int;
*p = 10;
cout<<*p<<"\t"<<p<<"\n";
delete p;
cout<<*p<<"\t"<<p<<"\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
10 0x237c010
0 0x237c010
在删除p之后,为什么指针p保持其值?不删除释放指针p?
究竟是什么意思'释放指针'?
"删除p"只是意味着'*p = 0'吗?(从输出看来)
我正在使用gcc 4.6.1.
代码段:
int main(void)
{
int x= 2;
int y = pow(3,x);
printf("%d\n",y);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
终奌站:
avinash@titanic:~/Desktop/DSF$ gcc power.c -o power
/tmp/ccTJ7vAH.o: In function `main':
power.c:(.text+0x25): undefined reference to `pow'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
如果我将x替换为2,那么它将以预期的方式执行.pow函数不接受变量作为参数吗?
注意:我在源文件中包含了stdio.h和math.h.