Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!
Quote:
Originally Posted by
2kaud
You have an extra } at the end of your code
It gotten there when I deleted some changes I tried - in the code I actually do not have extra }.
Still working on solution:-)
Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!
OK as I promised. There is nothing wrong with the code ( except that it is ugly and kinda mixes c-string with c++ - but that was the requirement). I re-did the files by copying and pasting, but under new location thoroughly watching each step - and it works now. No changes in the code so there is no need in posting it - who is interested - it is in the initial post.
Thanks everybody for participation - till next time!
Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!
Quote:
Originally Posted by
elenaq13
I have person.cpp in the project - I posted 3 files at the beginning - main.cpp, person.h and person.cpp. They do compile and work well only if I include #include "person.cpp" in the main (which I should not do). I checked some similar programs - and can't find my mistake to save my life.
For what it's worth, you should note that your code *does* compile. Rather, it does not *link*. This means there is nothing wrong with your code, and the compiler itself is perfectly happy with it.
It's the linker that is having trouble finding your compiled objects (in this case Person::setlastName). Linker errors are rarer and more obscure, so harder to deal with at first, but you'll get the hang of it:
90% of the time, it's because you declared a function, but either:
* Simply forgot to implement it.
* Implemented a function with a different name/type.
* Forgot to add "ClassName::" in implementation, which creates a different function.
The rest of the time, it's more complicated, and usually a configuration issue:
* Either the cpp is not in the project, and not compiled
* The libs you want to link against are not in your project
Honestly, that's just about it. Solving them is usually more trial & error though...
Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!
Quote:
Originally Posted by
monarch_dodra
Honestly, that's just about it. Solving them is usually more trial & error though...
I probably did not pay attention to the options when creating the file and missed to choose the language type or smthg else. Thank you for your response - very helpful and educating!
Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!
Being able to configure the used IDE properly for a particular solution/project - and use the debugger - is a skill that programmers need to learn as well as the language. Whilst there is available a great deal of information about how to write c++ programs, the information available as to how to actually and properly configure an IDE and use the debugger is much less readily available and often seems to be written assuming the person already knows much of it! :eek:
Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!
Quote:
Originally Posted by
2kaud
Being able to configure the used IDE properly for a particular solution/project - and use the debugger - is a skill that programmers need to learn as well as the language. Whilst there is available a great deal of information about how to write c++ programs, the information available as to how to actually and properly configure an IDE and use the debugger is much less readily available and often seems to be written assuming the person already knows much of it! :eek:
I agree. It is really frustrating to sit for hours (and I spent a couple of days as I am learning from scratch) - digging in the books about the code and finally find out that it is something else. This project is a small one so far, but it will grow as we'll have to add more features.
Can you recommend any literature or other resources?
Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!
Quote:
Originally Posted by
2kaud
Being able to configure the used IDE properly for a particular solution/project - and use the debugger - is a skill that programmers need to learn as well as the language. Whilst there is available a great deal of information about how to write c++ programs, the information available as to how to actually and properly configure an IDE and use the debugger is much less readily available and often seems to be written assuming the person already knows much of it! :eek:
I agree. It is really frustrating to sit for hours (and I spent a couple of days as I am learning from scratch) - digging in the books about the code and finally find out that it is something else. This project is a small one so far, but it will grow as we'll have to add more features.
Can you recommend any literature or other resources?
Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!
Quote:
Can you recommend any literature or other resources?
Sorry, no for Codeblocks as I don't use it - I use Microsoft Visual Studio (the Express version is free!). Maybe some other guru who uses Codeblocks can recommend?
Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!
Quote:
Originally Posted by
2kaud
Sorry, no for Codeblocks as I don't use it - I use Microsoft Visual Studio (the Express version is free!). Maybe some other guru who uses Codeblocks can recommend?
I use Visual Studio 2012 for Visual Basic. Tried it with C++ - was not able to do it intuitively - have to study the manual :-).