2. What will be the output of each of the following programs when it is executed? (a) #include using namespace std; struct abc { public: void dispabc(); struct xyz { public: void dispxyz(); }; };...




2. What will be the output of each of the following programs when it is executed? (a)


#include using namespace std; struct abc {


public:


void dispabc();






struct xyz { public:


void dispxyz();


};


};


void abc :: dispabc()


{


cout ”;


}


void abc :: xyz :: dispxyz()


{


cout <>


}


int main()


{














}


(b)




abc obj1; abc::xyz obj2; obj1.dispabc(); obj2.dispxyz(); return 0;




#include using namespace std; struct abc {


public:


void dispabc(); struct xyz {


public:


void dispxyz(); class pqr {


public:


void dispqr();


};


};


};


void abc :: dispabc()


{


cout <>


}


void abc :: xyz :: dispxyz()


{


cout <>


}


void abc :: xyz :: pqr :: dispqr()


{


cout <>


}


int main()


{


abc obj1; abc::xyz obj2;


abc::xyz::pqr obj3; obj1.dispabc(); obj2.dispxyz();














}


(c)




obj3.dispqr(); return 0;




#include using namespace std; struct abc {


private:


void dispabc(); struct xyz {


void dispxyz();


};


};


void abc :: dispabc()


{


cout <>


}


void abc :: xyz :: dispxyz()


{


cout <>


}


int main()


{














}


(d)




abc obj1; abc::xyz obj2; obj1.dispabc(); obj2.dispxyz(); return 0;




#include using namespace std; struct abc {


void dispabc(); private:


struct xyz {


void dispxyz();


};


};


void abc :: dispabc()


{


cout <>


}


void abc :: xyz :: dispxyz()


{


cout <>


}


int main()


{


abc obj1; abc::xyz obj2; obj1.dispabc(); obj2.dispxyz(); return 0;


}






(e)


#include using namespace std; struct abc {


void dispabc();


};


void abc :: dispabc()


{


cout <>


}


int main()


{










}


(f)




abc obj1; obj1.dispabc(); return 0;




#include using namespace std; struct abc {


private:


void dispabc();


};


void abc :: dispabc()


{


cout <>


}


int main()


{










}


(g)




abc obj1; obj1.dispabc(); return 0;




#include using namespace std; class abc{


public:


int a;


void setdata(const int a); void display();


};


void abc::setdata(const int aa)


{


a = aa;


}


void abc::display()


{


cout <><>


}


int main()


{


abc obj; obj.setdata(10);














}



(h)




obj.display(); return 0;




#include using namespace std; static class abc{


public:


int a;


void display();


};


void abc::display()


{


cout <><>


}


int main()


{


abc obj; obj.display(); return 0;


}














May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here