Class help

fixed
Last edited on
What exactly seems to fail? Does it not compile? Does it not run as expected? And what do you expect?

http://www.cplusplus.com/forum/general/112111/
Line 10 of your Main.cpp file

void ContactBook::AddContact(string forename, string surname, int phone, string address)

Line 19 of your BookContacts.h file

void AddContact(std::string forename, std::string surname, std::string phone, std::string address)


You basically have the phonenumber declared as a string in the header file but you are trying to pass an integer in your main.cpp.

You need to choose either int or string data type and work from there.
Your AddContact function definition and declaration do not match. Based on how you're using it in your main function, you should change the declaration to have an integer argument for phone number.
Thanks, I just changed line 10 to

void ContactBook::AddContact(string forename, string surname, int phone, string address)

and for line 19 so I make it as a int right?

void AddContact(std::string forename, std::string surname, std::int phone, std::string address)

I just want it to work and even changing it does not seem to let me compile :( I dont care if its a string or a int some one help lol


codeblocks error :


||=== Build: Debug in User (compiler: GNU GCC Compiler) ===|
E:\2\User\main.cpp||In function 'int main()':|
E:\2\User\main.cpp|96|error: invalid conversion from 'int' to 'const char*' [-fpermissive]|
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string.tcc|212|error: initializing argument 1 of 'std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' [-fpermissive]|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|



I got it to work thanks guys, you all are my hero's :D
Last edited on
Topic archived. No new replies allowed.