Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#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;
}

You have been given a Student class. Each student has a name variable. The user will provide a name, and you must create a new Student pointer, s, by dynamically allocating memory. If done correctly, the name of the student will be shown.

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;
}