OStream Operator overloading

Why is it that I am still getting this error after I overload the operator<<?
1
2
3
 	2	no operator "<<" matches these operands
            operand types are: std::ostream << MyPet::Pe
	



here is my code

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
#include <iostream>
#include <string>
#include <array>
using namespace std;
struct MyPet{

	enum class Pet{
		bird,eagle,
	};

	
};
std::ostream& operator<<(ostream &os, const MyPet& course)
{

	return os;
}


int main(){
	auto aw = MyPet::Pet::dog;
	cout << aw<< endl; // This is error
	system("pause");
}
}
Last edited on
Because your overload takes parameters of type MyPet, but aw is of type MyPet::Pet
I see.. Thanks.. I got it now
Topic archived. No new replies allowed.