Pages

Friday, May 16, 2025

Predicting the output of Friend class and function problem 1 in OOPs

 #include <iostream>

using namespace std;

class Parent {
public:
    Parent() {
        cout << "constructor of parent\n";
    }
    // destructor of Parent class
    ~Parent() {
        cout << "destructor of parent\n";
    }
};

class Child : public Parent {
public:
    Child() {
        cout << "constructor of child\n";
       
    }
     
    //Destructor of Child
    ~Child() {
        cout << "destructor of child\n";
    }


};

int main() {
    Child ch1;

    return 0;
}


OUTPUT:
constructor of parent
constructor of child
destructor of child
destructor of parent

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...