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

Could someone help me with this? I just need to fill in the code here part but i

ID: 645506 • Letter: C

Question

Could someone help me with this? I just need to fill in the code here part but i keep getting confused.

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.

#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 *s = new Student(name);
  
    cout << s->getName();
    return 0;
}