Thread: deriving classes

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    630

    deriving classes

    Hello..

    I have class cone, ctwo and class out_2 in base class (cone) which is derived from out class.
    I want to have out_2 virtual, so I can define it in class ctwo..
    I want to be able to call function out_func() and someotherfunc() from ctwo class.

    Code:
    class out {
    public:
    	void out_func() { }
    };
    
    class cone {
    public:
    
    	virtual class out_2 : public out { }
    	out_2 cobject;
    };
    
    class ctwo : public cone {
    public:
    	class out_2 : public out {
    	public:
    		void someotherfunc() { }
    	};
    	
    	////////
    	void call() {
    		cobject.out_func();
    		cobject.someotherfunc();
    	}
    };
    
    int main() {
    	ctwo class_two;
    	class_two.call();
    	return 0;
    }
    I hope you can see from the code, what Im trying to do..
    Last edited by l2u; 01-14-2007 at 12:09 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 10:47 AM
  2. Deriving from std::except
    By Mario F. in forum C++ Programming
    Replies: 5
    Last Post: 06-23-2007, 07:20 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 05:38 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM