Thread: Undeclared class

  1. #1
    Registered User
    Join Date
    May 2006

    Undeclared class

    Hey guys. I just started a few minutes ago working on a project and I think I've hit an interesting problem. I'm trying to use a friend's idea and make pure virtual base classes and inherit from them to make portable versions (i.e. you make a windows_gui_object or unix_gui_object inherit from basic_gui_object and such). However, I think I've hit a design flaw, here's the code:
    namespace gui
    	class basic_gui_object;
    	class basic_gui_surface : public basic_gui_object;
    	class basic_gui_object
    		virtual ~basic_gui_object();
    		virtual void Render(basic_gui_surface*) = 0;
    		void SetPosition(int, int);
    		int x, y;
    		static std::list<basic_gui_object*> ObjList;
    The compiler complained that it didn't know what basic_gui_surface was, so I pre-declared it but then, since basic_gui_surface inherits from basic_gui_object, it complained about basic_gui_object not being declared... so I pre-declared basic_gui_object as well and now it complains about basic_gui_object not being defined... I've tried adding braces at the end of each pre-declaration and -- of course -- I have defined basic_gui_object (without defining Render(), indeed). How could I fix this annoying problem ?

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    You only need to declare basic_gui_surface as

    class basic_gui_surface;
    It's the basic_gui_surface definition that needs the derivation list.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Inherite nonvirtual class functionality
    By DrSnuggles in forum C++ Programming
    Replies: 2
    Last Post: 04-30-2009, 01:52 PM
  3. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  4. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM