|
-
Dec 9th, 2001, 09:06 PM
#1
Thread Starter
Hyperactive Member
operator=
i have this class:
PHP Code:
class SubclassedObject {
public:
MessageAnswer MsgResponse; //
SubclassedObject operator= (SubclassedObject);
LRESULT CALLBACK SubclassWndProc(HWND hwnd, UINT Message, WPARAM wParam,
LPARAM lParam);
};
i have tried this as the operator=
PHP Code:
SubclassedObject SubclassedObject::operator = (SubclassedObject sobj)
{
this->MsgResponse = sobj.MsgResponse;
this->SubclassWndProc = sobj.SubclassWndProc;
return this;
}
but it gives me errors such as there
Code:
c:\my documents\subclasspractice\easysubclass.h(46) : error C2659: '=' : overloaded function as left operand
c:\my documents\subclasspractice\easysubclass.h(47) : error C2664: '__thiscall SubclassedObject::SubclassedObject(const class SubclassedObject &)' : cannot convert parameter 1 from 'class SubclassedObject *const ' to 'const class SubclassedObject &'
Reason: cannot convert from 'class SubclassedObject *const ' to 'const class SubclassedObject'
No constructor could take the source type, or constructor overload resolution was ambiguous
c:\my documents\subclasspractice\easysubclass.h(47) : error C2553: no legal conversion of return value to return type 'class SubclassedObject *'
can anyone help me? thanks
Amon Ra
The Power of Learning.
-
Dec 10th, 2001, 12:56 AM
#2
transcendental analytic
c:\my documents\subclasspractice\easysubclass.h(46) : error C2659: '=' : overloaded function as left operand
you are assigning a function, i guess it's not what you intend to do
c:\my documents\subclasspractice\easysubclass.h(47) : error C2664: '__thiscall SubclassedObject::SubclassedObject(const class SubclassedObject &)' : cannot convert parameter 1 from 'class SubclassedObject *const ' to 'const class SubclassedObject &'
Reason: cannot convert from 'class SubclassedObject *const ' to 'const class SubclassedObject'
No constructor could take the source type, or constructor overload resolution was ambiguous
c:\my documents\subclasspractice\easysubclass.h(47) : error C2553: no legal conversion of return value to return type 'class SubclassedObject *'
= should return a reference to *this change both in the header and the function
In fact unless you have any dynamically allocated data in your object, similar to copy constructors you could just assign the whole object: return *this=sobj;
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 10th, 2001, 10:46 AM
#3
Anyway, you can't assign a class member function as a wndproc...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|