Q
qazmlp1209
class base
{
public:
base()
{
}
base(int number)
{
priNumber = number ;
}
void pubFunc1()
{
// use 'priNumber' and do some tasks
}
void pubFunc2()
{
// use 'priNumber' and do some tasks
}
virtual void pubFunc3() = 0 ;
private:
int priNumber ;
} ;
class derived_one : public base
{
public:
derived_one()
{
base( 1 ) ;
}
void pubFunc3()
{
//
}
} ;
class derived_two : public base
{
public:
derived_two()
{
base( 2 ) ;
}
void pubFunc3()
{
//
}
};
I'm getting the compilation error: "Cannot create a value of the
abstract class base".
Only the objects of the derived classes make sense. Also, there is a
common implementation required for the pubFunc1 & pubFunc2 based on
the parameter 'priNumber' value. What is the other way of passing this
parameter to the base class function?
{
public:
base()
{
}
base(int number)
{
priNumber = number ;
}
void pubFunc1()
{
// use 'priNumber' and do some tasks
}
void pubFunc2()
{
// use 'priNumber' and do some tasks
}
virtual void pubFunc3() = 0 ;
private:
int priNumber ;
} ;
class derived_one : public base
{
public:
derived_one()
{
base( 1 ) ;
}
void pubFunc3()
{
//
}
} ;
class derived_two : public base
{
public:
derived_two()
{
base( 2 ) ;
}
void pubFunc3()
{
//
}
};
I'm getting the compilation error: "Cannot create a value of the
abstract class base".
Only the objects of the derived classes make sense. Also, there is a
common implementation required for the pubFunc1 & pubFunc2 based on
the parameter 'priNumber' value. What is the other way of passing this
parameter to the base class function?