2011-03-04 129 views
1

ISBN.cpp:8: error: 'ISBN' has not been declared类未声明? (C++)

ISBN.cpp:8: error: ISO C++ forbids declaration of 'ISBN' with no type ISBN.cpp: In function 'int ISBN()':

ISBN.cpp:9: error: 'area' was not declared in this scope

ISBN.cpp:10: error: 'publisher' was not declared in this scope

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

8号线至14是:

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

他们都在头部声明:

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

任何想法,这可能是这里的问题?我猜测它简单的东西我错过了。

+1

您可以尝试将格式整理出来吗?很难遵循全部在一行上的代码。缩进所有代码至少4个空格字符,它应该都会更好。 – 2011-03-04 21:54:48

+0

盲目猜测:循环头依赖经常会导致此问题,因为多重保护导致循环头第二次迭代包含失败默默。 – 2011-03-04 21:56:51

+2

你做过##包含在ISBN.cpp中的头文件,对不对? – aschepler 2011-03-04 21:58:24

回答

8

这看起来很明显,但是您是否仔细检查过您是否在ISBN.cpp中包含头文件?也许,你不小心使用了与两个头文件包括相同的预处理常量,导致文件的ISBN声明被有效忽略?您发布的代码片段对我来说看起来不错...

+1

+1“意外地使用了相同的预处理器常量”我看过的次数。 – Tony 2011-03-04 22:05:47