Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ ISO C&x2B+;禁止声明没有类型的职位_C++_Struct - Fatal编程技术网

C++ ISO C&x2B+;禁止声明没有类型的职位

C++ ISO C&x2B+;禁止声明没有类型的职位,c++,struct,C++,Struct,我在这里看到了几个类似的问题,但我似乎无法将他们的任何问题与我的程序相匹配。有人能帮我确定为什么它不允许我在.h文件中声明我的结构吗 我得到的错误是ISO禁止声明没有类型的“post” 提前谢谢,谢谢你看了我的档案 #include <iostream> 4 #include <cstring> 5 #include <cctype> 6 using namespace std; 7 8 // stuct to hold the indi

我在这里看到了几个类似的问题,但我似乎无法将他们的任何问题与我的程序相匹配。有人能帮我确定为什么它不允许我在.h文件中声明我的结构吗

我得到的错误是ISO禁止声明没有类型的“post”

提前谢谢,谢谢你看了我的档案

#include <iostream>
  4 #include <cstring>
  5 #include <cctype>
  6 using namespace std;
  7 
  8 // stuct to hold the individual posts
  9 
 10 struct post
 11 {
 12 
 13     int rating;
 14     char comment[];
 15     post * next;
 16 
 17 };
 18 
 19 //class to hold the functions as well as serve as a linked list of topics
 20 
 21 class blog
 22 {
 23 
 24     public:
 25 
 26         blog();
 27         ~blog(); 
 28         int post(char new_topic[], char new_comment[]);
 29         int display(char topic[]);
 30         int display_all();
 31         int rate(char topic[], char keyword[], int rating);
 32         int remove(char topic[], char keyword[]);
 33 
 34     private:
 35 
 36         blog * head;
 37         blog * tail; 
 38         blog * next;
 39         char * topic;
 40         post * next_post;
 41         post * last_post;
 42     
 43 };
#包括
4#包括
5#包括
6使用名称空间标准;
7.
8//stuct担任个人职务
9
10结构柱
11 {
12
13国际评级;
14 char评论[];
15个员额*下一个;
16
17 };
18
19//class保存函数并用作主题的链接列表
20
21类博客
22 {
23
24公众:
25
26博客();
27~ blog();
28 int post(char new_topic[],char new_comment[]);
29整数显示(字符主题[]);
30 int显示_all();
31整数比率(字符主题[],字符关键字[],整数评级);
32 int-remove(字符主题[],字符关键字[]);
33
34私人:
35
36名博客*负责人;
37博客*尾巴;
38博客*下一篇;
39个字符*主题;
40个职位*下一个职位;
41个职位*最后一个职位;
42
43 };

您有名称冲突。在
类博客
中,名称
post
指的是两种不同的东西。一个是
struct post
,另一个是成员函数


重命名其中一个。使用
::post
struct post
引用结构是另一种可能,但读者更容易混淆,因为您有名称冲突。在
类博客
中,名称
post
指的是两种不同的东西。一个是
struct post
,另一个是成员函数


重命名其中一个。使用
::post
struct post
引用结构是另一种可能,但读者更容易混淆,因为您有名称冲突。在
类博客
中,名称
post
指的是两种不同的东西。一个是
struct post
,另一个是成员函数


重命名其中一个。使用
::post
struct post
引用结构是另一种可能,但读者更容易混淆,因为您有名称冲突。在
类博客
中,名称
post
指的是两种不同的东西。一个是
struct post
,另一个是成员函数



重命名其中一个。使用
::post
struct post
引用结构是另一种可能性,但如果您的编译器足够复杂,能够输出发生错误的行号,则读者会更加困惑

。啊,对不起,我应该包括这一点。它说错误在第40行和第41行。我的错误。
post
是与函数相同的标识符吗?我想这会导致错误。另外,谢谢,
char comment[]
是非法的,可能会在到达
post
之前使编译器出错。您需要数组的大小,或者最好使用
std::string
。如果您的编译器足够复杂,能够输出发生错误的行号,那就好了……啊,对不起,我应该包括这一点。它说错误在第40行和第41行。我的错误。
post
是与函数相同的标识符吗?我想这会导致错误。另外,谢谢,
char comment[]
是非法的,可能会在到达
post
之前使编译器出错。您需要数组的大小,或者最好使用
std::string
。如果您的编译器足够复杂,能够输出发生错误的行号,那就好了……啊,对不起,我应该包括这一点。它说错误在第40行和第41行。我的错误。
post
是与函数相同的标识符吗?我想这会导致错误。另外,谢谢,
char comment[]
是非法的,可能会在到达
post
之前使编译器出错。您需要数组的大小,或者最好使用
std::string
。如果您的编译器足够复杂,能够输出发生错误的行号,那就好了……啊,对不起,我应该包括这一点。它说错误在第40行和第41行。我的错误。
post
是与函数相同的标识符吗?我想这会导致错误。另外,谢谢,
char comment[]
是非法的,可能会在到达
post
之前使编译器出错。您需要数组的大小,或者最好使用
std::string
。重命名的替代方法是使用namespace::指定结构,或者添加struct关键字,两者都可以。重命名的替代方法是使用namespace::指定结构,或者添加struct关键字,两者都应该起作用。重命名的备选方案是使用namespace::指定结构或添加struct关键字,两者都应该起作用。重命名的备选方案是使用namespace::指定结构或添加struct关键字,两者都应该起作用。