Plz tell output along with functioning and reasons!!! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Plz tell output along with functioning and reasons!!!

#include <iostream> #include <string> using namespace std; class per{ char name[20] ; float age; public: per(char *s,float a) { strcpy(name,s);age=a; } per & GR(per&x) {if(x.age>=age) return x; else return *this;} void display() {cout<<"Name:"<<name<<"\n"; cout<<"Age :"<<age<<"\n";}}; int main() { per P1("Ramu",27.5),P2("Raju",53),P3("Kalu",40); per P('\0',0); P=P1.GR(P3);P.display (); P=P2.GR(P3);P.display ();}

24th Mar 2017, 12:20 PM
Gaurav Kaushik
Gaurav Kaushik - avatar
1 Answer
+ 24
first add string.h header file it probably can give error in strcpy function
24th Mar 2017, 4:59 PM
Mansi Dagla
Mansi Dagla - avatar