Please Login in order to post a comment
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);
} void setlastname(const char *t) { strcpy(lastname,t); } void getlastname(char *a) { strcpy(a,lastname); } void setstandard(int standard) { this->standard=standard; } int getstandard() { return this->standard; }
}; 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<
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;
cin >> age >> first_name >> last_name >> standard; Student st; 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"; st.to_string(); return 0;
}
class info{ public: int age; char first_name[50]; char last_name[50]; int standard;
void print(int n,int standard,const char* first_name,const char* last_name){ cout<
cout<<n<<","<<first_name<<","<<last_name<<","<<standard;
}; int main() {
info obj1; int n; char first_name[50]; char last_name[50]; int standard; cin>>n; cin>>first_name; cin>>last_name; cin>>standard; obj1.print(n,standard,first_name,last_name); return 0;
class Student { private: int age; int standard; string first_name; string last_name;
public: void set_age(int a) { age=a; } void set_first_name(string fname) { first_name=fname; } void set_last_name(string lname) { last_name=lname; } void set_standard(int std) { standard=std; } int get_age() { return age; } string get_first_name() { return first_name; } string get_last_name() { return last_name; } int get_standard() { return standard; } string to_string() { stringstream ss; ss << age << "," << first_name << "," << last_name << "," << standard; return ss.str(); }
};
cin >> age >> first_name >> last_name >> standard; Student st; 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(); return 0;
#include <iostream> #include <sstream> using namespace std; class Student { private: int age; string first_name; string last_name; int standard; public: void set_age(int a) { age = a; } void set_first_name(string fname) { first_name = fname; } void set_last_name(string lname) { last_name = lname; } void set_standard(int std) { standard = std; } // Getter methods int get_age() { return age; } string get_first_name() { return first_name; } string get_last_name() { return last_name; } int get_standard() { return standard; } // Other methods 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; cin >> age >> first_name >> last_name >> standard; Student st; 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(); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
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;
}
include
include
include
include
include
include
using namespace std;
class info{ public:
int age; char first_name[50]; char last_name[50]; int standard;
void print(int n,int standard,const char* first_name,const char* last_name){ cout<
}
}; int main() {
}
include
include
using namespace std;
class Student { private: int age; int standard; string first_name; string last_name;
};
int main() { int age, standard; string first_name, last_name;
}