+ 1
How to make inheritance C++?
2 odpowiedzi
+ 2
class <class-name>: <visibility-mode> <name of the class from which will be inheritated>
visibility-mode: Three types: public, private or protected, which specifies that the inherited data will be public or private or protected in the derived class.
Ex.
class A
{
};
class B:public A
{
//code
};
0
ex.
class Myclass {
public:
void Sayhello () {
cout << "hello";
}
};
class myclassa: public Myclass {
sayhello ();
}
int main () {
myclassa a;
a.sayhello ();