help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

overloaded inserters and extractors


From: jalkadir
Subject: overloaded inserters and extractors
Date: 18 Oct 2005 14:40:37 -0700
User-agent: G2/0.2

I my program I have overloaded the inserters and extractor operator.
---name.hpp
    friend std::ostream& std::operator<<( std::ostream& os,
                                     const jme::Name& obj );
    friend std::istream& std::operator>>( std::istream& is,
                                     jme::Name& obj );
---name.cpp
std::ostream& std::operator<<( std::ostream& os, const jme::Name& obj )
{
    return os << obj.str;
}
std::istream& std::operator>>( std::istream& is, jme::Name& obj ) {
   return is >> obj.str;
}
------------------------
But this gives me an error that reads
Project   : Name
Compiler  : GNU GCC Compiler (called directly)
Directory : ..\dev\c++\jme\name\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.cpp
In file included from main.cpp:3:
name.hpp:83: error: `std::ostream& std::operator<<(std::ostream&, const
jme::Name&)' should have been declared inside `std'
name.hpp:85: error: `std::istream& std::operator>>(std::istream&,
jme::Name&)' should have been declared inside `std'
Process terminated with status 1 (0 minutes, 5 seconds)
 
---------------------


What am I doing wrong?

TIA



reply via email to

[Prev in Thread] Current Thread [Next in Thread]