1

ISBN.cpp:8: error: 'ISBN' has not been declared

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

Line 8 through 14 are:

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.

5
  • 1
    Could you try and get the formatting sorted out? It's really hard to follow code that's all on one line. Indent all your code by at least 4 space characters and it should all work better. Commented Mar 4, 2011 at 21:54
  • Blind guess: Circular header dependencies often cause this problem, as the multiple-include guards cause the second iteration round the circular header include to fail silently. Commented Mar 4, 2011 at 21:56
  • 2
    You did #include the header in ISBN.cpp, right? Commented Mar 4, 2011 at 21:58
  • Are you sure you want ten character pointers? char isbnStr[10]; looks more reasonable to me... Commented Mar 4, 2011 at 22:06
  • And std::string isbnStr; looks even more reasonable. Commented Mar 4, 2011 at 22:10

1 Answer 1

8

This might seem obvious, but have you double-checked that you actually include the header file in 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? The snippets you posted look fine to me…

Sign up to request clarification or add additional context in comments.

1 Comment

+1 for "accidentally used the same preprocessor constant" the number of times I have seen that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.