Error please help

I have this following code and following error is poping up!!!


error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or th
ere is no acceptable conversion)


code is:


using namespace std;

class personType
{
public:

void setName(string first, string last);
personType& setLastName(string last);
personType& setFirstName(string first);
void getName(string& first, string& last);
personType(string first = "", string last = "");
void print() const;
private:
string firstName;
string lastName;
};


using namespace std;
#include"personType.h"

personType& personType::setLastName(string last)
{
lastName = last;

return *this;
}

personType& personType::setFirstName(string first)
{
firstName = first;

return *this;
}

void personType::print() const
{
cout<<firstName
<<' '
<<lastName;
}

void personType::setName(string first, string last)
{
firstName = first;
lastName = last;
}

void personType::getName(string& first, string& last)
{
first = firstName;
last = lastName;
}

personType::personType(string first, string last)
{
firstName = first;
lastName = last;
}

#include<iostream>
using namespace std;

#include"personType.cpp"

int main()
{
personType student1("Angela", "Clodfelter");
personType student2;
personType student3;

cout<<"Line 4 -- Student 1: ";
student1.print();
cout<<endl;

student2.setFirstName("Shelly").setLastName("Malik");

cout<<"Line 8 -- student 2: ";
student2.print();
cout<<endl;

student3.setFirstName("Chelsea");

cout<<"Line 12 -- Student 3: ";
student3.print();
cout<<endl;

student3.setLastName("Tomek");

cout<<"Line 16 -- student 3: ";
student3.print();
cout<<endl;

return 0;
}



// Please help me out of this
Please post code with code tags (click the <> button on the right to generate the syntax).

Looks like sound code, though. Have you actually included <string>, though? And <iostream>?
Topic archived. No new replies allowed.