Thread View: comp.std.c++
1 messages
1 total messages
Started by Alan Teague
Tue, 26 Mar 1991 18:27
Pointer arguments for overloaded operators
Author: Alan Teague
Date: Tue, 26 Mar 1991 18:27
Date: Tue, 26 Mar 1991 18:27
34 lines
1561 bytes
1561 bytes
This is what I want to do:
class alpha {
...
// These are allowed and work with both g++ and ccxx:
friend alpha *operator+( alpha&, alpha& );
alpha *operator+( alpha& );
// This is what I really want to do:
friend alpha *operator+( alpha*, alpha* ); // Desired operation
// Not allowed by ARM: pg 330
// "An operator function must either be a member function or take
// at least one argument of a class or a reference to a class"
// The function I do not want to use, if possible, is:
alpha *alpha_append( alpha*, alpha* ); // Which works exactly the way I want.
// So I tried this:
alpha *operator+( alpha* ); // Compiles with no warnings or messages
// But when used, the use generates an error message:
// alpha *a = new alpha();
// alpha *b = new alpha();
// alpha *c = a + b; -- Error message about pointers
...
};
It seems to be perfectly reasonable to want to have the operator work on
pointers to class instances. Have I missed some subtle point which is not
discussed in the ARM commentary (or I haven't found yet)?
-- Alan Teague
teague@stc.lockheed.com
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