#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
class Person
{
private:
string name;
int age;
public:
string getName()
{
return name;
}
int getAge()
{
return age;
}
void setName(string myName)
{
name=myName;
}
void setAge(int myAge)
{
age=myAge;
}
Person(string myName, int myAge)
{
setName( myName);
setAge(myAge);
};
int main(int Args[])
{
Person people[100];
int count=0;
string name="";
int age =0;
cout<<"Enter name (-1 to stop): ";
cin >>name;
people[count].setName(name);
cout<<"Enter age of "<< name <<" :";
cin >> age;
people[count].setAge(age);
while(people.getName()=="-1")
{
count=count+1;
cout<<"Enter name (-1 to stop): ";
cin >>name;
people[count].setName(name);
cout<<"Enter age of "<< name <<" :";
cin >> age;
people[count].setAge(age);
}
for(int i=0; i<count; i++)
{
cout <<" Name: " << people[i].getName()<< ", age: "<< people[i].getAge()<< endl;
}
int min = people[0].getAge();
string minName = people[0].getName();
for(int i=0; i<count; i++)
{
for(int j=1; j<count; j++)
{
if (people[i].getAge() > people[j].getAge())
{
min = people[j].getAge();
people[j].setAge(people[i].getAge());
people[i].setAge(min);
minName = people[j].getName();
people[j].setName(people[i].getName());
people[i].setName(minName);
}
}
}
}
system("PAUSE");
return 0;
}
I don't know why it won't compile can someone please help me
86 C:\Users\tsrainey\Desktop\123.cpp ISO C++ forbids declaration of `system' with no type
86 C:\Users\tsrainey\Desktop\123.cpp expected `;' before '(' token
87 C:\Users\tsrainey\Desktop\123.cpp expected unqualified-id before "return"
C:\Users\tsrainey\Desktop\123.cpp In member function `int Person::main(int*)':
43 C:\Users\tsrainey\Desktop\123.cpp no matching function for call to `Person::Person()'
note C:\Users\tsrainey\Desktop\123.cpp:8 candidates are: Person::Person(const Person&)
note C:\Users\tsrainey\Desktop\123.cpp:8 Person::Person(std::string, int)
53 C:\Users\tsrainey\Desktop\123.cpp request for member `getName' in `people', which is of non-class type `Person[100]'
53 C:\Users\tsrainey\Desktop\123.cpp At global scope:
85 C:\Users\tsrainey\Desktop\123.cpp expected unqualified-id at end of input
85 C:\Users\tsrainey\Desktop\123.cpp expected `,' or `;' at end of input
Sorry it took time wouldn't let me just highlight them all
Thank you so much do u know where the others are