1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Polymorphism puzzle

Discussion in 'C++' started by evstevemd, Aug 28, 2010.

  1. evstevemd

    evstevemd New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    I have abstract base class with some kids deriving from it. I want its kids to be concrete classes But I don't want to implement the all methods of the class. I'm trying to find a trick to go around doing this and I'm running out of thought on this. below is illustrative code of what I want to do.

    Thanks for your help
    Code:
     class BaseDB {
            BaseDB();
            virtual ResultSet getResults()=0;
            virtual void setResults(std::string sql)=0;
            virtual void someMoreFunction()=0;
    
    };
    
    
    class FirstChild :public BaseDB {
            ResultSet getResults(){
                    //do some stuffs
            }
            
            void setResults(std::string sql){
                    //some more stuffs
            }
            
            //I don't want to implement someMoreFunction() in this class
    }
    
    class SecondChild :public BaseDB {
            ResultSet getResults(){
                    //do some stuffs
            }
            
            void someMoreFunction(){
                    //some more stuffs
            }
            
            //I don't want to implement setResults(std::string sql) in this class
    }
     

Share This Page