简体   繁体   English

未声明课程? (C ++)

[英]Class Not Declared?? (C++)

ISBN.cpp:8: error: 'ISBN' has not been declared ISBN.cpp:8:错误:尚未声明“ ISBN”

ISBN.cpp:8: error: ISO C++ forbids declaration of 'ISBN' with no type ISBN.cpp: In function 'int ISBN()': ISBN.cpp:8:错误:ISO C ++禁止声明没有类型ISBN的'ISBN'。cpp:在函数'int ISBN()'中:

ISBN.cpp:9: error: 'area' was not declared in this scope ISBN.cpp:9:错误:在此范围内未声明“区域”

ISBN.cpp:10: error: 'publisher' was not declared in this scope ISBN.cpp:10:错误:在此范围内未声明“发布者”

ISBN.cpp:11: error: 'title' was not declared in this scope ISBN.cpp:12: error: 'checkdigit' was not declared in this scope ISBN.cpp:13: error: 'isbnStr' was not declared in this scope ISBN.cpp:11:错误:未在此范围内声明“标题” ISBN.cpp:12:错误:未在此范围内声明“ checkdigit” ISBN.cpp:13:错误:未在此范围内声明“ isbnStr”范围

Line 8 through 14 are: 第8至14行是:

ISBN::ISBN() {
 area = NULL;
 publisher = NULL;
 title = NULL;
 checkdigit = NULL;
 isbnStr = NULL;
}

They are all declared in the header: 它们都在标头中声明:

class ISBNPrefix;
class ISBN
{
private:
 int area;
 int publisher;
 int title;
 char checkdigit;
 char* isbnStr[10];
public:
 ISBN();
...

Any ideas as to what could be the issue here? 关于这里可能有什么问题的任何想法? I'm guessing that its something simple I'm missing. 我猜想它缺少一些简单的东西。

This might seem obvious, but have you double-checked that you actually include the header file in ISBN.cpp ? 这看起来似乎很明显,但是您是否已仔细检查了您是否实际上在ISBN.cpp包含了头文件? Maybe, you have accidentally used the same preprocessor constant as include guard for two headers, causing the file with the declaration of ISBN to be effectively ignored? 也许您不小心使用了与两个头文件的包含保护相同的预处理程序常量,从而导致带有ISBN声明的文件被有效地忽略了? The snippets you posted look fine to me… 您发布的摘录对我来说很好...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM