小编Avi*_*ane的帖子

'删除指针'只是意味着'*指针= 0'吗?

# 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'吗?(从输出看来)

c++ free destructor memory-management delete-operator

5
推荐指数
1
解决办法
1193
查看次数

未定义C中电源功能的参考错误

可能重复:
在C中使用pow()的问题
未定义的对pow&#39; andfloor的引用'

我正在使用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.

c gcc pow

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

c ×1

c++ ×1

delete-operator ×1

destructor ×1

free ×1

gcc ×1

memory-management ×1

pow ×1