Why am I getting "No operator matches..."

After I write cout, the first "<<" is giving me a squigle red line saying that no operator matches these operands. Solution?

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include "Person.h"

using namespace std;

Person::Person(string first, string last, int arbitrary)
       : firstname(first), lastname(last), arbitraryNumber(arbitrary)
{
	cout << firstname << "" << lastname << endl;
}
If anyone comes across this, the solution is to add:

#include <string>
Do you understand why though? The "<<" pair is known as an operator, each class has it's own set of instructions that describe what to do when they encounter these or other operators. Those instructions need to be declared before you use them on that or any other class, this is done by including the header file for the class.
Topic archived. No new replies allowed.