You are viewing a single comment's thread. Return to all comments →
#include <bits/stdc++.h> // #include<string.h> using namespace std; class Student { private: int age,std; string fn, ln; public: int get_age() { return age; } string get_first_name() { return fn; } string get_last_name() { return ln; } int get_standard() { return std; } void set_age(int x) { age=x; } void set_first_name(string s) { fn=s; } void set_last_name(string s) { ln=s; } void set_standard(int x) { std=x; } string to_string() { stringstream ss; string s,s1; ss<<age; ss>>s; ss.clear(); ss<<std; ss>>s1; s=s+","+fn+","+ln+","+s1; return s; } }; int main() { int age,std; string fn,ln; Student s1; cin>>age>>fn>>ln>>std; s1.set_age(age); s1.set_standard(std); s1.set_first_name(fn); s1.set_last_name(ln); cout<<s1.get_age()<<endl; cout<<s1.get_last_name()<<", "<<s1.get_first_name()<<endl; cout<<s1.get_standard()<<"\n"<<endl; cout<<s1.to_string(); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Class
You are viewing a single comment's thread. Return to all comments →