CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 4 of 4 FirstFirst 1234
Results 46 to 59 of 59
  1. #46
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Unresolved external symbol

    Quote Originally Posted by crisdeveloper View Post
    if i don´t put namespace in Person.h it not works because the strings types. what the best way to do it?
    Put it in .cpp file(s)
    Victor Nijegorodov

  2. #47
    Join Date
    May 2013
    Location
    // Brazil
    Posts
    51

    Re: Unresolved external symbol

    finally we make this program works well!! thanks for every one that spend time to help me.

    the program works fine with namespace in Person.h, but if i try

    std::string getName ()const { return Name; }

    the error continues

  3. #48
    Join Date
    May 2013
    Location
    // Brazil
    Posts
    51

    Re: Unresolved external symbol

    obs.: namespace are in cpp and .h

  4. #49
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Unresolved external symbol

    Quote Originally Posted by crisdeveloper View Post
    obs.: namespace are in cpp and .h
    Take the "using namespace std" out of the .h file. Use the namespace within the .cpp file only.

    Regards,

    Paul McKenzie

  5. #50
    Join Date
    May 2013
    Location
    // Brazil
    Posts
    51

    Re: Unresolved external symbol

    when i retire the namespace from .h it no works!

  6. #51
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Unresolved external symbol

    Quote Originally Posted by crisdeveloper View Post
    when i retire the namespace from .h it no works!
    That is because your program is still not set up properly.

    There should be no "using namespace std" in the Person.h header file. If there is, remove it and fix the problem. Otherwise you have in front of you a badly assembled program, regardless of whether it runs or not, and you haven't really learned how to properly put together a real C++ program.

    First, what is not working? Does the program compile? If not, what are the errors? Post the current Person.h header file.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; May 14th, 2013 at 01:30 PM.

  7. #52
    Join Date
    May 2013
    Location
    // Brazil
    Posts
    51

    Re: Unresolved external symbol

    the program works well, saves, edit, and display the data.

    but i would like to know how i can optmize my code.

  8. #53
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Unresolved external symbol

    Quote Originally Posted by crisdeveloper View Post
    the program works well, saves, edit, and display the data.
    But programming is much more than seeing a program "work". What about the way you've put together the program? Things like this:
    Code:
    try
        {
            string TEMP;
            ifstream DATAFILE;
            DATAFILE.open("Data1.file",ios::in);
            getline (DATAFILE,TEMP);
    
            cg->setName (TEMP);
            getline (DATAFILE,TEMP);
    
            cg->setLocation (TEMP);
            getline (DATAFILE,TEMP);
    
            cg->setAge (TEMP);
            getline (DATAFILE,TEMP);
    
            cg->setOccupation (TEMP);
            DATAFILE.close();
        }
        catch (exception x)
        {
            cout<<"\n\t File Error! Unable to load data.";
        }
    Why is there a try/catch here? What function in the "try" throws an exception? If none of those lines throws an exception, then try/catch is not necessary.

    Second, even if you wanted to write a catch block, the exception can be caught by reference, not by value.
    but i would like to know how i can optmize my code.
    Before you can even consider optimizing anything, you need to know and use the C++ language much better than your current level. For example, there wasn't one const or usage of references anywhere in the original code you posted. Usage of const and references is important in optimizing C++ code.

    Last, we have no idea what your current code looks like.

    Regards,

    Paul McKenzie

  9. #54
    Join Date
    May 2013
    Location
    // Brazil
    Posts
    51

    Re: Unresolved external symbol

    in the reality i took this code from a forum to study c++, maybe it seems not a good idea but i´ve learned a lot is these 2 days trying to solve the code from another person.

    give me a good reference of a c++ book, and thanks for your advice.

  10. #55
    Join Date
    May 2013
    Location
    // Brazil
    Posts
    51

    Re: Unresolved external symbol

    you can close this topic, because i´m newbie in this forum and i don´t know how i can do it.

  11. #56
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Unresolved external symbol

    You might like to look at these web sites

    http://www.learncpp.com/
    http://www.cplusplus.com/doc/tutorial/

    There are many, many c++ books available. For an intro to c++, I like the Ivor Horton books. Then there are the Deitel books which are often recommended. There are the Sams Teach Yourself c++ range of books which some find useful from which to learn. Note that there is a new ANSI c++ standard - c++11 - which only books published very recently will cover. The previous ANSI standard from 1998 was covered properly in books from about 2002. If you buy older second hand c++ books look at their #include statements. If they have #include <iostream.h> then the book doesn't cover ansi c++. If it has #include <iostream> then it probably does.

    Hope this helps.
    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++23 Compiler: Microsoft VS2022 (17.6.5)

  12. #57
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Unresolved external symbol

    Quote Originally Posted by crisdeveloper View Post
    you can close this topic, because i´m newbie in this forum and i don´t know how i can do it.
    A thread isn't closed. But you can mark it as resolved.

    See http://forums.codeguru.com/faq.php?f..._item_resolved
    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++23 Compiler: Microsoft VS2022 (17.6.5)

  13. #58
    Join Date
    May 2013
    Location
    // Brazil
    Posts
    51

    Re: [RESOLVED] Unresolved external symbol

    thanks for these links, both are very helpfull for me!

  14. #59
    Join Date
    May 2013
    Location
    // Brazil
    Posts
    51

    Re: [RESOLVED] Unresolved external symbol

    i found more errors in this project for example: the data was overwriting the last information typed, but i fitted this errors.


    i´ve made a lot of modifications in this project before i leave it, if someone want to check i uploaded it in this link:

    http://www.4shared.com/rar/cE-7u1wF/...ss__in__c.html

Page 4 of 4 FirstFirst 1234

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