Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Tom Keffer
Tue, 01 Aug 1989 14:34
Cast bug?
Author: Tom Keffer
Date: Tue, 01 Aug 1989 14:34
Date: Tue, 01 Aug 1989 14:34
30 lines
1144 bytes
1144 bytes
It was my impression that under C++, the cast notations A(B) and (A)B
are equivalent when casting a B as an A. This is not always true
under g++ 1.35.0. Here is a code strip that illustrates the
difference:
class A {
};
class B {
public:
operator A();
};
void foo(A&);
main()
{
B b;
foo( A(b) ); // Error: type `A' does not have a constructor
foo( (A)b ); // OK
}
-tk
---
Dr. Thomas Keffer | Internet: keffer@sperm.ocean.washington.edu
School of Oceanography | BITNET: keffer%sperm.ocean.washington.edu@UWAVM
Univ. of Washington, WB-10 | uucp: uw-beaver!sperm.ocean.washington.edu!keffer
Seattle, WA 98195 | Telemail: T.KEFFER/OMNET
(206) 543-6455
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