Let just say that we have two classes, A
and B
.
Here is code for both of them
class A
{
public:
int x;
};
class B
{
public:
int y;
void FindY() { y = x + 12; }
};
void something()
{
A fs;
B fd;
fs.x = 10;
fd.FindY();
}
the problem is that i want to access x but i don't wanna pass anything as argument to my function i look at friend and inheritance but both didn't seem to help me, correct me if i'm wrong.
some how i need to find x in function FindY()
.
I'm going with the static method but in my case i get this error.
Error 2 error LNK2001: unresolved external symbol "public: static class std::vector<class GUIDialog *,class std::allocator<class GUIDialog *> > Window::SubMenu" (?SubMenu@Window@@2V?$vector@PAVGUIDialog@@V?$allocator@PAVGUIDialog@@@std@@@std@@A) C:UsersOwnerdocumentsvisual studio 2010ProjectsMonopolyMonopolyWindow.obj
Here is how i declared it
static vector<GUIDialog *> SubMenu;
I get that error because of this line
SubMenu.resize(3);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…