|
-
July 3rd, 2010, 09:25 AM
#3
Re: Halp with my program?
WOW! THAT'S IT? Wow....just wow!!! I am seriously sorry for wasting your time. By the way, is my way of creating a dynamic memory correct because when it comes to pointer and all i am not very confident. Also, i modified the program so that it can take in the name "John Connor" without error by putting in a getline code but there seems to be a looping problem which i do not understand. Mind checking it out? Thank you for your time spent on answering my menial question. I understand some of you guys are programming gurus and have better and more important things to do. I am truly sorry if i wasted any of your time.
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;
getline(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;
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|