Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I wirte a .hpp file? (template, friend ,class,overload )?

0 views
Skip to first unread message

maigre_dragon

unread,
Dec 28, 2009, 8:23:13 AM12/28/09
to
//example.h
template <typename T> class C;
template <typename T>
std::ostream& operator<< (std::ostream& os, const C<T>& x); //why ? Must
declare in place!?
//template<typename T> std::ostream& operator<<(std::ostream& os, const
C<char*>& x);
//template<typename T> std::ostream& operator <<(std::ostream& os, const
C<char*>& x);
//
template<typename T>
class C{
public:
//snip
protected:
friend std::ostream& operator<< <T>(std::ostream& os, const C<T>& x);
//why? Must have a <T> before the (std::ostream& os ..) !?
// friend std::ostream& operator<< <char*>(std::ostream& os ,const
C<char*>& x); //instant !? No complied! Why?
// friend std::ostream& operator<< (std::ostream& os, const C<char*>&
x); // overload !? No complied! Why?
private:
//snip
};
//
std::ostream& operator<< (std::ostream& os, const C<T>& x){ //OK! It can
define now!
//snip
}
//special template! No linked! Why?
template<> std::ostream& operator <<(std::ostream& os, const C<char*>& x){
//snip
}
//overload ! No linked! Why?
std::ostream& operator <<(std::ostream& os, const C<char*>& x){
//snip
}
//

red floyd

unread,
Dec 29, 2009, 3:25:39 PM12/29/09
to
On Dec 28, 5:23 am, maigre_dragon <maigre_dra...@126.com> wrote:
[redacted]

See the FAQ, in particular 5.4, 5.7, and 5.8.

Since there was no question in your post, I'm going to assume the
subject line is your question.

How do you write a .hpp file? With a text editor.

maigre_dragon

unread,
Dec 30, 2009, 8:00:58 AM12/30/09
to
Thank you. I have found my answer in
http://www.parashift.com/c++-faq-lite/index.html.

0 new messages