🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #832

Re: operator<< and namespace

#832
From: Al-Burak
Date: Wed, 19 Oct 2005 16:00
49 lines
2468 bytes
Correction
I accidentally forgot to add the name of the namespace

--------- strtools.hpp
namespace jme{
calss strtools{
   std::string str;
   ........

};
}

--------- name.hpp
namespace jme{
class Name : public jme::strtools{
    ....
    // This only gives you an idea as to what the f'tions do
    const std::string& getNameStr() const{return str;}
    void setName( const std::string& x){str = x;}
    void setName( const char* x){str = x;}

   friend std::ostream& operator<<( std::ostream& os,
                                     const jme::Name& obj );
   friend std::istream& operator>>( std::istream& is,
                                     jme::Name& obj );

};
}

--------- name.cpp
std::ostream& operator<<( std::ostream& os, const jme::Name& obj ) {
return os << obj.getNameStr(); }
std::istream& operator>>( std::istream& is, jme::Name& obj ) {
   return is >> obj.str;

}

--------- main.cpp
   jme::Name name("ni\xa4" "a");

   std::cout << "\"" << name << "\"" << std::endl;

   std::cout << "End of name..." << std::endl;
   std::cin.get();
   return 0;

}

========================================
Technical Details
Message-ID: <1129737626.090999.134650@g49g2000cwa.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!g49g2000cwa.googlegroups.com!not-for-mail
References: <1129731313.976379.198160@g49g2000cwa.googlegroups.com> <m27jc94izy.fsf@madbox2.local>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114592,beb845dd377bccf0
X-Google-Thread: 10ba33,beb845dd377bccf0
X-Google-Attributes: gid114592,gid10ba33,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!g49g2000cwa.googlegroups.com!not-for-mail
From: "Al-Burak" <jalqadir@netscape.net>
Newsgroups: alt.comp.lang.learn.c-c++,gnu.g++.help
Subject: Re: operator<< and namespace
Date: 19 Oct 2005 09:00:26 -0700
Organization: http://groups.google.com
Lines: 50
Message-ID: <1129737626.090999.134650@g49g2000cwa.googlegroups.com>
References: <1129731313.976379.198160@g49g2000cwa.googlegroups.com>
   <m27jc94izy.fsf@madbox2.local>
NNTP-Posting-Host: 66.38.206.135
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1129737631 22334 127.0.0.1 (19 Oct 2005 16:00:31 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 19 Oct 2005 16:00:31 +0000 (UTC)
In-Reply-To: <m27jc94izy.fsf@madbox2.local>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: g49g2000cwa.googlegroups.com; posting-host=66.38.206.135;
   posting-account=CVIbKA0AAACqi9AW7QjGQcvTa4Gtl-O4