forward declaration of std::ostream

Advertisements The files are organized as following: //MyClass.h #pragma once namespace std { class ostream; }; class MyClass { private: int a; public: friend std::ostream& operator<<(std::ostream& o, const MyClass& obj); }; //MyClass.cpp #include<iostream> std::ostream& operator<<(std::ostream& o, const MyClass& obj) { o << obj.a << std::endl; return o; } //main.cpp #include"MyClass.h" #include<iostream> int main() { MyClass… Read More forward declaration of std::ostream