Thread View: comp.sys.sgi.bugs
1 messages
1 total messages
Started by J. Gabriel Foster
Fri, 18 Dec 1992 20:18
c++ question/bug?
Author: J. Gabriel Foster
Date: Fri, 18 Dec 1992 20:18
Date: Fri, 18 Dec 1992 20:18
105 lines
2794 bytes
2794 bytes
Hello,
I have a question about CC 3.0. I am trying to overload the << function
on a class that is enclosed within another class. As far as I can tell
from Ellis & Stroustrup's "The Annotated C++ Reference Manual" this
is a valid thing to do. For an example of my problem, look at
test1.c and test2.c (given below). test1.c compiles, but test2.c does
not. Why does test2.c not work? My compiler versions and example
source code follow.
Thank you for your time,
--> Gabe Foster
> J. Gabriel Foster (fop@gwha.com)
> GW Hannaway & Associates, 839 Pearl Street, Boulder, CO 80302
> Voice: (303)440-9631, Fax: (303)440-4421
fop@spice<1>versions -n c++
I = Installed, R = Removed
Name Version Description
I c++ 707182570 C++, 3.0
I c++.hdr 1006310004 C++ Headers
I c++.hdr.lib 1006310004 C++ Library Headers
I c++.man 1006310004 C++ Manual Pages
I c++.man.c++ 1006310004 C++ Compiler Man Pages
I c++.man.relnotes 1006310004 C++ Release Notes
I c++.sw 1006310004 C++ Software
I c++.sw.c++ 1006310004 C++ Compiler
I c++.sw.lib 1006310004 C++ Libraries
I c++.sw.libC 1006310004 C++ library
fop@spice<2>cat test1.c
// test1.c
// version WITHOUT name space protection via an enclosing class
class AA {
public:
AA& operator<<( int v ) { v = v; return *this; }
};
class AAA {
friend AA& operator<<( AA& aa, AAA& v );
};
class AAB {
friend AA& operator<<( AA& aa, AAB& v );
};
AA&
operator<<( AA& aa, AAA& v )
{
v = v;
return aa;
}
AA&
operator<<( AA& aa, AAB& v )
{
v = v;
return aa;
}
main( )
{
}
fop@spice<3>CC test1.c
fop@spice<4>cat test2.c
// test2.c
// version WITH name space protection via an enclosing class
class A {
public:
class AA {
public:
AA& operator<<( int v ) { v = v; return *this; }
};
class AAA {
friend AA& operator<<( AA& aa, AAA& v );
};
class AAB {
friend AA& operator<<( AA& aa, AAB& v );
};
};
A::AA&
operator<<( A::AA& aa, A::AAA& v )
{
v = v;
return aa;
}
A::AA&
operator<<( A::AA& aa, A::AAB& v )
{
v = v;
return aa;
}
main( )
{
}
fop@spice<5>CC test2.c
"test2.c", line 25: error: two definitions of operator <<()
fop@spice<6>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads