My teacher asked me to simply create a scenario in C++ that uses an array of objects.
Well, i followed everything by book yet weird problem appears. What is wrong? My take is that the dynamic addressing part has problem. What is the problem? Thanks in advance.
Code:
#include<iostream>
#include<string>
using namespace std;

class kill
{

string name;
public:
void inName(string name);
string outName();
};

void kill::inName(string name)
{
    this->name=name;
}

string kill::outName()
{
    return name;
}

int main()
{
int size;
kill* peopleyouhate;
cout<<"Insert the amount of people you wanna terminate"<<endl;
cin>>size;
peopleyouhate= new kill[size];
for(int i=0; i<size; i++)
{
string name;
cout<<"Insert the name of the person you wanna terminate"<<endl;
cin>>name;
peopleyouhate[i].inName(name);
}

cout<<"These are the people you wanna terminate, there is no more turning back..."<<endl;
for(int j=0; j<size; j++)
{
cout<<peopleyouhate[j].outName<<endl;
}

return 0;
}