Results 1 to 5 of 5

Thread: oo problem

  1. #1

    Thread Starter
    Ya ya Baby!!!Me is Back
    Join Date
    Jul 2002
    Posts
    362

    Talking oo problem

    Ok here is the problem in a cpp file :

    PHP Code:

    #include "barreprinc.h"


    void BarrePrinc::AddMenu(string sNameMenu)
    {
        
    //Put the new menu in the vector
        
    vMenuList.push_back(Menu(sNameMenu));
        
    //Ajust the size of the menu that we have
        
    SetLen(GetLen() - sNameMenu.length());
    }
    //End BarrePrinc::AddMenu

    void BarrePrinc::AddSubMenu(string sNameMenustring sNameSubMenu)
    {
        for (
    int i 0vMenuList.size(); i++)
        {
            if (
    vMenuList[i].GetMenuName() == sNameMenu)
            {
                
    vMenuList[i].AddSubMenu(sNameSubMenu);
            }
    //End if
        
    }//End for : i


    }//End BarrePrinc::AddSubMenu 
    Header:

    PHP Code:
    #include <string>
    #include <vector>
    #include "menu.h"

    using namespace std;

    class 
    BarrePrinc
    {
        private:
            
    //Hold empty space in the bar
            
    unsigned short int iBarLen;
            
    //Contain all Menu in this vector
            
    vector<MenuvMenuList;
            
    //Change the empty space that the bar can hold
            
    void SetLen(unsigned short int iLen){iBarLen iLen;}
            
    unsigned short int GetLen(){return iBarLen;}
        public:
            
    //Constructor
            
    BarrePrinc():iBarLen(80){};
            
    //Functions
            
    void AddMenu(string sNameMenu);
            
    void AddSubMenu(string sNameMenustring sNameSubMenu);

    };
    //End class : BarrePrinc 

    Why I got that error :

    Compiling...
    barrePrinc.cpp
    main.cpp
    Linking...
    barrePrinc.obj : error LNK2001: unresolved external symbol "public: void __thiscall Menu::AddSubMenu(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?AddSubMenu@Menu@@QAEXV?$basic_string@DU?$char_traits@D@s
    td@@V?$allocator@D@2@@std@@@Z)
    Debug/MyFirstMenuInDos.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

  2. #2
    New Member
    Join Date
    Aug 2002
    Posts
    3
    Wow, that's a tough one.

    Geez....I don't know.

  3. #3

    Smile

    hi MasterDaok,
    Can you put the sourec code of the project in the Attiment file
    to see the proplem and go to sulve it...
    thank .
    rajab natshah

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You must have missed adding Menu.cpp to your project...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Ya ya Baby!!!Me is Back
    Join Date
    Jul 2002
    Posts
    362
    I found it!

    The error was that I got 2 function with the same name, one in menu and one in submenu. Now I changed that and all worked well.

    I think I need to watchout about overloading function and go read back some note but now it works

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