syntax error identifier string.
Hi,
I'm getting an error C2061: syntax error : identifier 'string'. Could you help me please?
1 2 3 4 5 6 7 8
|
class Person
{
public:
Person(string stName);
virtual void Print() const;
private:
string m_stName;
};
|
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#include <iostream>
#include <string>
#include "Person.h"
Person::Person(string stName)
:m_stName(stName)
{
//Empty
}
void Person::Print() const
{
cout << "Name: " << m_stName << endl;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
#include "Person.h"
#include "Student.h"
#include "Employee.h"
using namespace std;
void main()
{
Person person("John Smith");
person.Print();
cout << endl;
Student student("Mark Jones", "MIT");
student.Print();
cout << endl;
Employee emloyee("Adam Brown", "Microsoft");
employee.Print();
cout << endl;
Person* pPerson = &person;
pPerson->Print(); //calls print in person
cout << endl;
pPerson = &student;
pPerson->Print(); //calls print in student
cout << endl;
pPerson = &emloyee;
pPerson->Print(); //calls print in employee
}
|
thanks in advance for your help
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
#include <string>
#include "Person.h"
namespace std;
Person::Person(string stName)
:m_stName(stName)
{
//Empty
}
void Person::Print() const
{
cout << "Name: " << m_stName << endl;
}
|
I noticed I forgot namespace std; but it still has the error
Last edited on
I get about 500 errors from this project. Oh well maybe it was setup wrong. and its actually 81 errors
Last edited on
Topic archived. No new replies allowed.