Create a class to represent a student with methods to set and get the student’s name and ID.
HardProblem Statement
Create a class to represent a student with methods to set and get the student’s name and ID.
Sample Input
Student s; s.setName("John Doe"); s.setID(123);Sample Output
Student Name: John Doe, ID: 123
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <iostream>
#include <string>
class Student {
private:
std::string name;
int id;
public:
void setName(std::string n);
void setID(int i);
void display();
};
int main() {
// Logic to demonstrate Student functionality
return 0;
}
Input
Student s; s.setName("John Doe"); s.setID(123);Expected Output
Student Name: John Doe, ID: 123