We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<sstream>#include<string>usingnamespacestd;/*Enter code for class Student here.Read statement for specification.*/classStudent{private:intst_age;stringst_first_name;stringst_last_name;intst_standard;public:Student():st_age(0),st_standard(0){}voidset_age(constintage){st_age=age;}voidset_standard(constintstandard){st_standard=standard;}voidset_first_name(conststring&name){st_first_name=name;}voidset_last_name(conststring&lastName){st_last_name=lastName;}intget_age(){returnst_age;}stringget_last_name(){returnst_last_name;}stringget_first_name(){returnst_first_name;}intget_standard(){returnst_standard;}stringto_string(){conststringx=std::to_string(st_age);conststringy=std::to_string(st_standard);conststrings=x+","+st_first_name+","+st_last_name+","+y;returns;}};intmain(){intage,standard;stringfirst_name,last_name;cin>>age>>first_name>>last_name>>standard;Studentst;st.set_age(age);st.set_standard(standard);st.set_first_name(first_name);st.set_last_name(last_name);cout<<st.get_age()<<"\n";cout<<st.get_last_name()<<", "<<st.get_first_name()<<"\n";cout<<st.get_standard()<<"\n";cout<<"\n";cout<<st.to_string();return0;}
include
include
using namespace std;
/* Enter code for class Student here. Read statement for specification. */ class Student{ private : int age , standard; string first_name; string last_name; public : Student(){} Student(int Age , string firstName , string lastName , int Standard){ set_age(Age); set_first_name(firstName); set_last_name(lastName); set_standard(Standard); } int get_age(){ return age; } void set_age(int Age){ age=Age; } string get_first_name(){ return first_name; } void set_first_name(string firstName){ first_name=firstName; } string get_last_name(){ return last_name; } void set_last_name(string lastName){ last_name=lastName; } int get_standard(){ return standard; } void set_standard(int Standard){ standard=Standard; } string to_string(){ stringstream ss; ss << age << "," << first_name << "," << last_name << "," << standard; return ss.str(); } }; int main() { int age, standard; string first_name, last_name;
}
My C++ code 😎😁
include
include
using namespace std; class student { private: int age; char firstname[21]; char lastname[21]; int standard; public: void setage(int age) { this->age=age; } int getage() { return this->age; } void setfirstname(const char *t) { strcpy(firstname,t); } void getfirstname(char *a) { strcpy(a,firstname);
}; int main() { student s; s.setage(15); s.setfirstname("john"); s.setlastname("carmack"); s.setstandard(10); char fr[21]; char ls[21]; s.getfirstname(fr); s.getlastname(ls); cout<
include
include
using namespace std;
class Student{ private: int age; string first_name; string last_name; int standard; public : void set_age(int a){ age=a; } int get_age(){ return age; } void set_first_name(string fname){ first_name=fname; } string get_first_name(){ return first_name; } void set_last_name(string lname){ last_name=lname; } string get_last_name(){ return last_name; } void set_standard(int s){ standard=s; } int get_standard(){ return standard; } void to_string(){ cout<
int main() { int age, standard; string first_name, last_name;
}