You are viewing a single comment's thread. Return to all comments →
Sorry but why do I have to write std::to_string if I declared the library I was using. Heres the code, I mean
class Student { private: int Age; string Name; string Last_Name; int Standard;
public: void set_age(int age) { Age = age; } void set_standard(int standard) { Standard = standard; } void set_first_name(string name) { Name = name; } void set_last_name(string last_name) { Last_Name = last_name; } int get_age() { return Age; } int get_standard() { return Standard; } string get_first_name() { return Name; } string get_last_name() { return Last_Name; } string to_string() { string Final; Final = std::to_string(Age) + ',' + Name + ',' + Last_Name + ',' + std::to_string(Standard); return Final; }
};
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
Class
You are viewing a single comment's thread. Return to all comments →
Sorry but why do I have to write std::to_string if I declared the library I was using. Heres the code, I mean
class Student { private: int Age; string Name; string Last_Name; int Standard;
};
int main() { int age, standard; string first_name, last_name;
}`