patilsanketv
BAN USER
Questions (3)
Reputation 5
- -1of 1 vote
AnswersWhy here output is not Derived Class????
- patilsanketv in India
#include <iostream>
using namespace std;
class Base {
public:
char* name;
void display() {
cout << name << endl;
}
};
class Derived: public Base {
public:
char* name;
void display() {
cout << name << ", " << Base::name << endl;
}
};
int main() {
Derived d;
d.name = "Derived Class";
d.Base::name = "Base Class";
Derived* dptr = &d;
// standard conversion from Derived* to Base*
Base* bptr = dptr;
// call Base::display()
bptr->display();
}
// OUTPUT
Base Class| Report Duplicate | Flag | PURGE
Google Developer Program Engineer C++
Page:
1
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.