-
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 sNameMenu, string sNameSubMenu)
{
for (int i = 0; i < vMenuList.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<Menu> vMenuList;
//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 sNameMenu, string 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.
-
Wow, that's a tough one.
Geez....I don't know.
-
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
:)
-
You must have missed adding Menu.cpp to your project...
-
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 :)