C++意外标识符
C++ unexpected identifier
#include "cs163hw1.h"
extras::extras(int num_cats){
head = new category_node;
head->next = NULL;
head->category = num_cats;
category_node * temp;
for(int i = 1; i < (num_cats); ++i){
temp = new category_node;
temp->next = head;
head = temp;
head->category = (num_cats-i);
}
}
extras::~extras(){
category_node * temp;
while(head->next){
temp = head;
head = head->next;
delete temp;
}
delete head;
}
extras::int print_cats(){
category_node * current;
while(current){
cout << current->category << endl;
current = current->next;
}
return 1;
}
我在 print_cats 之前在 int 处收到一个无法识别的标识符错误。 自从我使用 c++ 以来已经有一段时间了,但我想我记得缺少 ";" 错误,但在我的一生中,我还没有找到它。
不确定,但应该改用"int extras::print_cats()
"。
int extras::p rint_cats()如果这是一种方法。
这将
适用于int extras::print_cats()
。只是一个小的语法错误。
你可能不是说extras::int
,而是int
。 唯一有意义的方法是,如果你在命名空间或类中有一个名为 int 的 typedef(这将是一个坏主意)。
相关文章:
- 在C++中,是否可以基于给定的标识符创建基类的新实例,反之亦然
- #ifdef和未声明的标识符
- 在C++中对T*类型执行std::move的意外行为
- 使用取消引用的指针的多态性会产生意外的结果.为什么?
- 处理除以零会导致<csignal>意外行为
- f2、f3、f4标识符未找到
- vscode下的Arduino代码出现意外编译错误
- 使用++运算符会导致意外的结果
- 套接字读取后,我在缓冲区中看到意外输入
- 更改.cpp程序的输入文件中数据的位置会意外更改输出
- 使用vscode调试时,GDB意外退出
- 设置 Visual Studio for MPI: 找不到标识符错误
- 未声明的标识符编译暗黑破坏神 2 程序"muleview"
- 在顶点着色器中使用 OpenGl 的未声明标识符,我在顶点着色器中绘制三角形时遇到问题
- Google protobuf 时间戳未声明标识符,在 Windows 上具有C++
- 此测试()中发生了什么意外过程?为什么总是覆盖 ch[0 1 2..]?
- 错误 C2760:语法错误:映射迭代器上意外的标记"标识符",预期的";"
- 未声明的标识符和类型"int"从 main 调用类时出现意外错误
- C++意外标识符
- 在visual studio中编译意外的(未声明的标识符)错误