hello. hadn't coded in c++ in a while and am trying to do an assignment. the prompt is
Implement a class Person with two fields name and age, and a class Company with three fields:
• the company name
• a pointer to the CEO (a Person*)
• a pointer to a FOUNDER (a Person*)
Write a program that prompts the user to specify people and companies. Store them in a vector<Person*> and a vector<Company*>. Traverse the vector of Person objects and increment their ages by one year. Finally, traverse the vector of Companies and print out the company name, CEO name and age, and founder’s name and age.
i think i have coded everything i need to but can't get it to compile and dont understand the errors it's giving me. More specifically, i think the problem is the compiler not recognizing string as a type, since almost all the errors contain a variable or function i used the string type on. what can i do to fix this? here is my code
#include <iostream>
#include <string>
#include "Person.h"
#include "Company.h"
int main()
{
int ages[100];
int cCount = 0;
int i = 0;
int j = 0;
string names[100];
string tempC;
string tempCEO;
string tempFOUNDER;
vector<Person*> people;
vector<Company*> companies;
char ans = 'y';
while (ans = y)
{
cout << "enter name of person: ";
cin >> names[i];
cout << "enter the age of that person: ";
cin >> ages[i];
cout << "enter another person(y for yes, n for no)?: ";\
cin >> ans;
tolower(ans);
i++;
}
constint numPeople = i;
for ( int i = 0; i < numPeople; i++)
{
Person *a = new Person(names[i], ages[i]);
people.push_back(a);
}
ans = y;
i = 0;
while (ans = y)
{
cout << "enter a company name: ";
cin >> tempC;
Company *b = new Company( tempC );
companies.push_back(b);
cout << "who is the CEO of this company?: ";
cin >> tempCEO;
cout << "who is the founder of this company?: ";
cin >> tempFOUNDER;
for (int x = 0; x < numPeople; x++)
{
if ( tempCEO == people[i] )
b.Company::set_CEO(people[i]);
}
for (int x = 0; x < numPeople; x++)
{
if ( tempFOUNDER == people[i] )
b.Company::set_FOUNDER(people[i]);
}
cout << "enter another company? (y for yes n for no): ";
cin >> ans;
tolower(ans);
cCount++;
}
for( int x = 0; x < numPeople; x++)
{
people[x]->increment_age;
}
forint x = 0; x < cCount; x++
{
companies[x]->print();
}
}