|
-
Oct 7th, 2001, 05:25 PM
#1
Problem with classes
Im still learning classes, so could someone please tell me why i get this error...
Code:
Error E2235 wndmain.cpp 14: Member function must be called or its address taken in function wndmain::wndmain()
Heres the files...
wndmain.cpp
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "wndmain.h"
wndmain::wndmain()
{
WNDCLASSEX WndClassEx;
hIconMain = LoadIcon(NULL, IDI_APPLICATION);
hCursorArrow = LoadCursor(NULL, IDC_ARROW);
WndClassEx.cbSize = sizeof(WNDCLASSEX);
WndClassEx.lpfnWndProc = WndProc;
WndClassEx.style = CS_HREDRAW | CS_VREDRAW;
return;
}
wndmain::~wndmain()
{
DestroyIcon(hIconMain);
DestroyCursor(hCursorArrow);
return;
}
LRESULT CALLBACK wndmain::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return(0);
}
wndmain.h
Code:
class wndmain
{
public:
wndmain();
~wndmain();
protected:
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static HICON hIconMain;
static HCURSOR hCursorArrow;
};
The error is with this line in wndmain.cpp...
Code:
WndClassEx.lpfnWndProc = WndProc;
Anything would be helpful.
-
Oct 7th, 2001, 05:33 PM
#2
transcendental analytic
2 solutions:
1. make the callback function static and virtually inherit the class to extend it.
2. don't contain the function, in other words have a function pointer.
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.
-
Oct 7th, 2001, 05:51 PM
#3
How do i do either of those?
-
Oct 7th, 2001, 07:47 PM
#4
transcendental analytic
1. add static and virtual specifiers to the declaration of the callback, then derive a class using virtual functions
2. add a member specifying the function pointer to a LRESULT CALLBACK (*proc)(HWND, UINT , WPARAM , LPARAM ); and use it for WNDCLASSEX. you could initialize this to a default proc in the constructor or have it passed there, or/and use accessors.
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.
-
Oct 8th, 2001, 12:14 AM
#5
I spent the last little while trying to do either of those, and i realized, i have no idea what to do. I have a pretty good understanding of c and c++, just not when it comes to pointers and inheritance (dont even know what that is). Could you show an example please. Thanks.
-
Oct 8th, 2001, 04:00 AM
#6
transcendental analytic
Inheritance is a very very important concept in object oriented programming, if you learn it now, you'll have benefit of it the rest of your life, have a look at Sam's teach yourself C++ in 21 days and pick up what you missed.
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.
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
|