LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2947|回复: 0

关于gdb中的No symbol "xxxxxxx" in current context.

[复制链接]
发表于 2007-4-8 17:07:17 | 显示全部楼层 |阅读模式
#include<iostream.h>
#include<string.h>
class prompt
{
private:
  char *_temp;

public:
    prompt (const char *p);
   ~prompt ();
  const char *getstring ();
};
int
main ()
{
  prompt *p_prompt = new prompt ("hi! please  enter string : ");
  cout << "you entered :" << p_prompt->getstring () << endl;
  delete p_prompt;
  return 0;
}

prompt:: prompt (const char *p)
{
  const int SIZE = 100;
  char *temp = new char[SIZE];
  cout << p << endl;
  cin.getline (temp, SIZE);
  //char *                                              //line  28
  _temp = new char[strlen (temp) + 1];
  strcpy (_temp, temp);
  delete[]temp;
}

prompt::~prompt ()
{
  delete[]_temp;
}
const char *
prompt::getstring ()
{
  return _temp;
}

两个问题:
i)我在gdb中始终看不到temp(print  temp),提示 No symbol "temp" in current context;而能看到_temp;
  这是为什么?
ii)若把第28行的注释去掉,执行的结果将会不同,会出错。
   这又为何?
   
谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表