I'm just starting out in C++ (coded a lot in Java and some hobby stuff in PHP) and I just ran into this weird problem:
I have 2 classes, MainWindow (QMainWindow) & PokerTableInfo (QWidget). The layout for both of them uses a gridLayout. The MainWindow consists of a label and multiple instances of PokerTableInfo (so I got an #include PokerTableInfo.h in MainWindow). Now, so far so good, everything actually worked fine, but then I started cleaning up some code (MainWindow originally had multiple inheritance and it was unnecessary & made things ugly). In the declaration of both classes I have:
Now, for some reason the linker is telling me that there's multiple definitions of gridLayout. I don't quite get this... Sure, the variables have the same type & name, but they're both in a completely different class (and private on top of that as well, not that it should matter). I have a MainWindow.gridLayout and a MainWindow.PokerTableInfoInstance.gridLayout, how and where does this become a problem?
I'm used to working in Java and I never encountered something weird like that even though I use the same variable name for general stuff all the time (String lblName, etc.,...). So, can anyone explain to me why I'm getting this error and how to fix it? (Apart from the obvious renaming of the variable.)
Bookmarks