(C )节点标题的语法错误
(c++) Syntax errors for node header
我正在为此标题分配语法错误和令牌错误。
#pragma once
#include "Book.h"
#include <string>
using namespace std;
/**
* This is a node class, they will hold object
* data and nodes will be utilized in List class
*/
class Node
{
public:
/**
* Purpose: Default constructor
* Parameters: none
* Returns: none
* Pre-conditions: none
* Post-conditions: NULL node is added to Linked List
*/
Node();
/**
* Purpose: De-constructor
* Parameters: none
* Returns: none
* Pre-conditions: none
* Post-conditions: Node is deleted
*/
~Node();
/**
* Purpose: Parameterized constructor
* Parameters: Book
* Returns: none
* Pre-conditions: none
* Post-conditions: node is added to Linked List
* with data
*/
Node(Book* B);
/**
* Purpose: Name getter
* Parameters: none
* Returns: Book
* Pre-conditions: Item name is not NULL
* Post-conditions: none
*/
Book* getBook();
/**
* Purpose: Next node getter
* Parameters: none
* Returns: Pointer for next node in list
* Pre-conditions: Must have another node in list ahead of this
* Post-conditions: none
*/
Node* getNextNode();
/**
* Purpose: Next node setter
* Parameters: pointer for next node in list
* Returns: none
* Pre-conditions: none
* Post-conditions: List has new node ahead of this
*/
void setNextNode(Node* a);
private:
Book* thisBook;
string itemName;
string itemType;
int itemNum;
Node* nextNode;
};
一切似乎都在井井有条,但是我得到了这些错误
Error C2061 syntax error: identifier 'Book' 38
Error C2535 'Node::Node(void)': member function already defined or declared 38
Error C2143 syntax error: missing ';' before '*' 47
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int 47
Error C2238 unexpected token(s) preceding ';' 47
Error C2143 syntax error: missing ';' before '*' 68
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int 68
Error C2238 unexpected token(s) preceding ';' 68
我正在创建一个链接列表,这些类型的错误也出现在我的列表中。我缺少某种减速吗?至于第二个错误,它指向参数化的构造函数。
编辑:书籍定义代码
#pragma once
#include "Node.h"
#include "List.h"
#include <string>
using namespace std;
/**
* Class designed to store information
* of a book. This class is the BASE.
*/
class Book
{
private:
string author;
string title;
double price;
public:
/**
* Purpose: Default constructor
* Parameters: none
* Returns: none
* Pre-conditions: none
* Post-conditions: none
*/
Book();
/**
* Purpose: Constructor
* Parameters: author, address, price
* Returns: none
* Pre-conditions: none
* Post-conditions: variables saved
*/
Book(string, string, double);
/**
* Purpose: Getter for Author class
* Parameters: none
* Returns: Author class
* Pre-conditions: none
* Post-conditions: none
*/
string getAuthor();
/**
* Purpose: Getter for title
* Parameters: none
* Returns: title
* Pre-conditions: title must have been saved
* Post-conditions: none
*/
string getTitle();
/**
* Purpose: Getter for price
* Parameters: none
* Returns: price
* Pre-conditions: price must have been saved
* Post-conditions: none
*/
double getPrice();
};
如果这两个标头都包含在同一文件中,具体取决于在Book
Node
的顺序为了解决此依赖关系,请确保它们包含在正确的顺序中,或者在class Node
Book
class Book;
class Node
{
...
};
相关文章:
- 为什么包含windows.h会产生语法错误,从而阻止类的实例化?(C2146,C2065)
- 错误 C2760:语法错误:映射迭代器上意外的标记"标识符",预期的";"
- 为什么我会收到错误 C2143 语法错误:缺少"*"之前的';'?
- 奇怪的代码抛出编译错误模板< J,int aSize=10> C2143:语法错误:在"<"之前缺少";"
- "错误 C0000:语法错误,令牌"<EOF>"处出现意外$end,并且不确定
- 我该怎么做才能摆脱使用命名空间时的语法错误?
- 如何摆脱错误c2061;语法错误 cout?
- 语法错误:D3DX10Core 中的标识符'TEXTMETRICA'
- 错误 C2146:语法错误:标识符"A1"之前缺少","
- main.cpp(11):错误 C2059:语法错误:"字符串"
- RedisGraph 语法错误在偏移量 8 靠近"创建"
- 如何修复此 FSM C++语法错误 C3867
- 函数错误 C2059:语法错误:'>'不起作用
- 为什么在main()之前断言会导致语法错误"error: expected ')' before numeric constant"?
- c++default-int中的语法错误
- "pip install openexr"上的语法错误:错误的编译器?
- 为什么我收到语法错误:在"*"之前缺少";"
- 错误 C2059:语法错误:从结构成员声明'constant'
- C++语法错误,编译器不会警告或 int v = func(&v) 出错;
- 我正在调试这个C++程序.编译器不再显示语法错误,但存在隐藏的逻辑错误