By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,961 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,961 IT Pros & Developers. It's quick & easy.

operators and namespaces

P: n/a
Hi,

I have a question about operators. I have something similar to the
following code:

//================
// file a.h
class A { ... };

// file op.h
namespace s {
template<typename T>
A& operator<<( A& a, T const& t ) { ...; return a; }
}

// file prog.cxx
void f() {
A a;
int i=0;
a << i;
}
//================

How can I specifiy the namespace for the operator? I tried

a << s::operator<< i;

but my compiler does not like it and I actually have no idea how it
should be.

Best wishes,

Alexander
Apr 11 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Alexander Bürger wrote:
I have a question about operators. I have something similar to the
following code:

//================
// file a.h
class A { ... };

// file op.h
namespace s {
template<typename T>
A& operator<<( A& a, T const& t ) { ...; return a; }
}

// file prog.cxx
void f() {
A a;
int i=0;
a << i;
}
//================

How can I specifiy the namespace for the operator? I tried

a << s::operator<< i;

but my compiler does not like it and I actually have no idea how it
should be.


s::operator <<(a, i);

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.