A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C++ program to demonstrate example of simple inheritance
Q:

C++ program to demonstrate example of simple inheritance

0

C++ program to demonstrate example of simple inheritance

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Simple inheritance program in C++.

/*C++ program to demonstrate example of simple inheritance.*/

#include <iostream>
using namespace std;
 
/*Base Class*/
class A
{
    public:
        void Afun(void);
};
// function definiion
void A::Afun(void)
{
    cout << "I'm the body of Afun()..." << endl;
}
 
/*Derived Class*/
class B:public A
{
    public:
        void Bfun(void);
};
// function definition
void B::Bfun(void)
{
    cout << "I'm the body of Bfun()..." << endl;
}
 
int main()
{
    //create object of derived class - class B
    B objB;
    // Now, we can access the function of class A (Base class)
    objB.Afun();
    objB.Bfun();
    return 0;
}

Output

I'm the body of Afun()...
I'm the body of Bfun()...

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now