//using namespace std;
using std::ifstream;
using std::ofstream;
using std::cout;
class Dog
{
friend ostream& operator<< (ostream&, const Dog&);
public:
char* name;
char* breed;
char* gender;
Dog();
~Dog();
};
< < 연산자를 오버로드하려고합니다. 좋은 코딩을 연습하려고합니다. 그러나 네임 스페이스 std를 사용하여 주석을 제거하지 않으면 내 코드가 컴파일되지 않습니다. 나는이 오류가 계속 발생하고 나는 모른다. 메신저 g ++ 컴파일러를 사용하여.연산자 << 과부하
Dog.h:20: error: ISO C++ forbids declaration of ‘ostream’ with no type
Dog.h:20: error: ‘ostream’ is neither function nor member function; cannot be declared friend. if i add line using std::cout; then i get this error.
Dog.h:21: error: ISO C++ forbids declaration of ‘ostream’ with no type.
누군가가 네임 스페이스 표준을 사용하여 함께 < < 연산자를 오버로드 나에게 올바른 방법을 말할 수있다;