I am starting to create my GUI toolkit project for the X Window System, and I created these classes, each of which has a .h and .cpp file:
Dimension (actually contains 3 classes, Dimension, FloatDimension, and BoolDimension): An object to contain an x, y pair.
Application: Initializes the resources used by the widgets, manages the event loop.
TopLevelWindow: A window.
Each of these individually compile into a .o file just fine, but my test program that uses them gives an error:
In case you don't know the g++ command, this is an explanation in english:Code:#include "Dimension.h" #include "Application.h" #include "TopLevelWindow.h" int main() { Application app; TopLevelWindow win(app, "Test", Dimension(3, 3)); win.pack(); win.show(); app.eventLoop(); return 0; }
g++ compile-only-no-linker include-library-X11 file:src/main.cpp
I have no idea what's going on. Can anyone help me fix this?Code:$ g++ -c -lX11 src/main.cpp In file included from src/TopLevelWindow.h:5, from src/main.cpp:4: src/Application.h:3: error: redefinition of ‘class Application’ src/Application.h:3: error: previous definition of ‘class Application’ In file included from src/TopLevelWindow.h:7, from src/main.cpp:4: src/Dimension.h:1: error: redefinition of ‘class Dimension’ src/Dimension.h:1: error: previous definition of ‘class Dimension’ src/Dimension.h:10: error: redefinition of ‘class FloatDimension’ src/Dimension.h:10: error: previous definition of ‘class FloatDimension’ src/Dimension.h:18: error: redefinition of ‘class BoolDimension’ src/Dimension.h:18: error: previous definition of ‘class BoolDimension’ src/main.cpp: In function ‘int main()’: src/main.cpp:7: error: no matching function for call to ‘TopLevelWindow::TopLevelWindow(Application&, const char [10], Dimension)’ src/TopLevelWindow.h:16: note: candidates are: TopLevelWindow::TopLevelWindow(Application*, std::string, Dimension) src/TopLevelWindow.h:8: note: TopLevelWindow::TopLevelWindow(const TopLevelWindow&)



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.