C2143 缺少 '*' 之前的';' 和 C 4430 缺少类型说明符 - 假定为 int。注意 C++ 不支持 default-int
C2143 missing ';' before '*' & C 4430 missing type specifier - int assumed. note c++ does not support default-int
这段代码接受几个输入文件,然后使用getline函数将输入文件中的行放在一个链表中。我猜有一个关于创建链表的问题,因为它给出了一个错误"错误C2039: 'down':不是'函数'的成员以及标题上指定的错误。我不知道C2130 &C4430 错误。
#include <iostream>
#include <fstream>
#include <string>
#include "strutils.h"
using namespace std;
struct Functions
{
string fname;
Functions *right;
Commands *down;
};
struct Commands
{
string command;
Commands *next;
};
Functions *head = nullptr;
Functions *temp = nullptr;
void printLinkedList()
{
Functions *ptr = head;
while (ptr != nullptr)
{
cout << ptr->fname << endl;
while (ptr->down != nullptr)
{
cout << ptr->down->command + " ";
ptr->down = ptr->down->next;
}
cout << endl;
ptr = ptr->right;
}
}
您需要向前声明Commands
结构:
struct Commands;
struct Functions
{
string fname;
Functions *right;
Commands *down;
};
struct Commands
{
string command;
Commands *next;
};
在Functions
之前添加Commands
的前向声明:
struct Commands;
struct Functions {
...
}
相关文章:
- 为什么在全局范围内使用"extern int a"似乎不行?
- int(c) 和 c-'0' 之间的区别。C++
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 为什么野牛仍在使用"int yylex(void)",却找不到"int yylex(YYS
- 有符号的int和int-有没有一种方法可以在C++中区分它们
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- 是否可以从int转换为enum类类型
- 不能在初始值设定项列表中将非常量表达式从类型 'int' 缩小到'unsigned long long'
- 向量 <int> a {N, 0} 和 int arr a[N] = {0} 的时间复杂度有什么区别
- 'short int'持有的值溢出,但"自动"不会溢出?
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- 调用'begin(int [n])'没有匹配函数
- 没有显式声明的int[]中的foreach
- 在c++中访问int到类对象的映射时出错
- 为什么我无法更改"set<set>"循环中的值<int>
- 长 长 int 不要 长 int 好
- C++程序在循环后给出奇怪的int值
- 如何计算数据类型的范围,例如int
- 如果"new int"返回"int*",那么为什么"new int[n]"不返回"int**"?
- 如何在cpp.中使用协议缓冲区存储大缓冲区/数组(char/int)