CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    Join Date
    Nov 2014
    Posts
    13

    Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!

    Quote Originally Posted by 2kaud View Post
    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:-)

  2. #17
    Join Date
    Nov 2014
    Posts
    13

    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!

  3. #18
    Join Date
    Jun 2009
    Location
    France
    Posts
    2,513

    Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!

    Quote Originally Posted by elenaq13 View Post
    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...
    Is your question related to IO?
    Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
    It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.

  4. #19
    Join Date
    Nov 2014
    Posts
    13

    Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!

    Quote Originally Posted by monarch_dodra View Post
    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!

  5. #20
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,551

    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!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++20 Compiler: Microsoft VS2019 (16.11.5)

  6. #21
    Join Date
    Nov 2014
    Posts
    13

    Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!

    Quote Originally Posted by 2kaud View Post
    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!
    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?

  7. #22
    Join Date
    Nov 2014
    Posts
    13

    Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!

    Quote Originally Posted by 2kaud View Post
    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!
    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?

  8. #23
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,551

    Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!

    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?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++20 Compiler: Microsoft VS2019 (16.11.5)

  9. #24
    Join Date
    Nov 2014
    Posts
    13

    Re: class peson err.15|undefined reference to `Person::setlastName(char*)' help!!!

    Quote Originally Posted by 2kaud View Post
    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 :-).

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured