Note: C++ does not support default-int

here is the header file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class BookType{
private:
	string title[200];
	string author[200];
	string publisher[200];
	string edition[200];
	int id[200];
	int counter=0;
public:
	void AddBook(int,string,string,string,string);
	//--to add a book
	//--postcondition: add the book to the library
	int getID(int)const;
	string getAUTHOR()const;
	string getTITLE()const;
	string getPUBLISHER()const;
	string getEDITION()const;
};



the implementation file
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include "Book.h"
#include <string>

using namespace std;

void BookType::AddBook(int id,string title,string author,string publisher ,string edition)
{ //code
counter++;
}



here errors
1>------ Build started: Project: oop, Configuration: Debug Win32 ------
1>Compiling...
1>BookType.cpp
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(4) : error C2146: syntax error : missing ';' before identifier 'title'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(4) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(4) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(5) : error C2146: syntax error : missing ';' before identifier 'author'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(6) : error C2146: syntax error : missing ';' before identifier 'publisher'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(7) : error C2146: syntax error : missing ';' before identifier 'edition'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(9) : error C2864: 'BookType::counter' : only static const integral data members can be initialized within a class
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(11) : error C2061: syntax error : identifier 'string'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(15) : error C2146: syntax error : missing ';' before identifier 'getAUTHOR'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(15) : warning C4183: 'getAUTHOR': missing return type; assumed to be a member function returning 'int'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(16) : error C2146: syntax error : missing ';' before identifier 'getTITLE'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(16) : warning C4183: 'getTITLE': missing return type; assumed to be a member function returning 'int'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(17) : error C2146: syntax error : missing ';' before identifier 'getPUBLISHER'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(17) : warning C4183: 'getPUBLISHER': missing return type; assumed to be a member function returning 'int'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(18) : error C2146: syntax error : missing ';' before identifier 'getEDITION'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(18) : warning C4183: 'getEDITION': missing return type; assumed to be a member function returning 'int'
1>c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\booktype.cpp(8) : error C2511: 'void BookType::AddBook(int,std::string,std::string,std::string,std::string)' : overloaded member function not found in 'BookType'
1>        c:\users\speedserver\documents\visual studio 2008\projects\oop\oop\book.h(2) : see declaration of 'BookType'
1>Build log was saved at "file://c:\Users\SpeedServer\Documents\Visual Studio 2008\Projects\oop\oop\Debug\BuildLog.htm"
1>oop - 27 error(s), 4 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited on
Make sure you include <string> and either use namespace std or append std:: to each time you mention string.

1
2
3
4
5
6
7
8
#include <string>
using std::string; // "using namespace std" would also work, but is unnecessary and can cause problems down the road

int main()
{
    string str; // std::string if you comment out line 2
    return 0;
}
Last edited on
thanks in advance
it's working
Topic archived. No new replies allowed.