diff widget.h~ widget.h 8c8 < myColor backColor(); --- > myColor backColor;
--- In [email protected], "Jimmy Johnson" <boxer...@...> wrote: > > I am getting the following errors and I am pulling my hair out. If someone > could help I would greatly appreciate it. As I don't know where this is > coming from, I included the files I think are relavant but who knows? Each > class has a header and a cpp file. > > window.cpp(14) : error C2228: left of '.red' must have class/struct/union > window.cpp(14) : error C2228: left of '.green' must have class/struct/union > window.cpp(14) : error C2228: left of '.blue' must have class/struct/union > > > ***************** widget.h ************ > > #ifndef WIDGET_H > #define WIDGET_H > #include "myColor.h" > > class widget { > public: > widget(); > myColor backColor(); > void setBackColor (const myColor a_color); > bool wasBackColorSet; > widget *parent; > // The widet in which Current resides (emmediate parent). > widget *rootWidget(); > // The window that is closest to Current up the tree. > // This is the widget which has the callbacks, and to which > // positioning and sizing is relative. > myColor backColorImp; > // Implementation so `backColor' can be calculated. > // Really want to use references, not value, here. > }; > > #endif > > *************** widget.cpp *********** > // widget.cpp > > myColor widget::backColor() { > if (wasBackColorSet) { > return backColorImp; > } else { > if (parent == NULL) { > return defaultBackColor; > } else { > return parent.backColor(); > }; > }; > }; > > > ********************** window.h ************ > #ifndef WINDOW_H > #define WINDOW_H > #include "widget.h" > > class window : public widget { > public: > window(); > }; > > #endif > > > ******************** window.cpp************ > #include <iostream> > #include <typeInfo> > #include <GL\glut.h> > #include "window.h" > #include "myColor.h" > > using namespace std; > > window::window() : widget () { > // Initialize Current by calling precursor and then set > // up some openGL states. > cout << "Call constructor for " << typeid (this).name() << endl; > // Performs certain window initalizations > glClearColor (backColor.red, backColor.green, backColor.blue, 0.0); > glColor3f (foreColor.red, foreColor.green, foreColor.blue); > glMatrixMode (GL_PROJECTION); // set "camera shape" > glLoadIdentity (); // clearing the viewing matrix > }; > > > > **************************** myColor.h **************** > #ifndef MY_COLOR_H > #define MY_COLOR_H > > class myColor { > public: > myColor(); > myColor (float aRed, float aGreen, float aBlue); > float red; > float green; > float blue; > void set (float aRed, float aGreen, float aBlue); > }; > > static myColor White (1.0, 1.0, 1.0); > static myColor Black (0.0, 0.0, 0.0); > static myColor Red (1.0, 0.0, 0.0); > static myColor Green (0.0, 1.0, 0.0); > static myColor Blue (0.0, 0.0, 1.0); > > #endif > > > *********************** myColor.cpp *************** > #include "myColor.h" > > myColor::myColor () { > // Default color is white > set (0.0, 0.0, 0.0); > }; >
