(gdb) b breakpoints.cpp:X::X()
Can't find member of namespace, class, struct, or union named "breakpoints.cpp:X::X"
Hint: try 'breakpoints.cpp:X::X()<TAB> or 'breakpoints.cpp:X::X()<ESC-?>
(Note leading single quote.)
Make breakpoint pending on future shared library load? (y or [n]) n
Run Code Online (Sandbox Code Playgroud)
在以下代码中:
#include <stdio.h>
#include <iostream>
class X
{
public:
X ()
{
std :: cout << "\nIn the default constructor";
}
X (int)
{
std :: cout << "\nIn the parameterized constructor";
}
~X () {}
};
int main (int argc, char *argv[])
{
X xObjA;
X xObjB (11);
while (--argc > 0)
{
printf("\n%s ", argv [argc]);
}
std :: cout << std :: endl << std :: endl;
}
Run Code Online (Sandbox Code Playgroud)
文件名是:breakpoints.cpp
我错过了什么意思?
这才是设置断点的正确方法。
您要么在错误的可执行文件上尝试(将breakpoints.cpp放入目录中并使用g++ -g Breakpoints.cpp进行编译,然后在a.out可执行文件上使用gdb),代码与发布的代码不同并且可能具有名称空间,或者您由于使用过时的 gdb 版本而偶然发现了一个旧错误。