#pragma once #include <iostream> #include <string> using namespace std; class St
ID: 645504 • Letter: #
Question
#pragma once
#include <iostream>
#include <string>
using namespace std;
class Student
{
private:
string name;
public:
Student(string name);
string getName();
~Student();
};
Student::Student(string studentName)
{
name = studentName;
}
string Student::getName()
{
return name;
}
Student::~Student()
{
}
int main()
{
string name;
cin >> name;
//
// Code Here
//
cout << s->getName();
return 0;
}
Explanation / Answer
#pragma once
#include <iostream>
#include <string>
using namespace std;
class Student
{
private:
string name;
public:
Student(string name);
string getName();
~Student();
};
Student::Student(string studentName)
{
name = studentName;
}
string Student::getName()
{
return name;
}
Student::~Student()
{
}
int main()
{
string name;
cin >> name;
student Name1;
Name1.Student(name); // pass name of student
cout << Name1.getName();// for display the name of student
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.