|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Godday
Im quiet new in programming and got some problems. Im coding C++ in win XP I was trying to make a class witch contained all the WinMain and Message Proc stuff. I ran into some problems when i came to the part with the function pointer to the message proc in the CreateWindow Command (or was it Registerwindow??). It seems strange to me, the same code worked the moment before only it wasnt in a class then. Is it so that one cant create pointers to functions in classes from another function in the same class in the defeniton?? Is this a known issue, or have i only made a fool out of myself once again? Help me!! Im getting nuts over this problem. You can also email me: URL // Emil |
|
#2
|
|||
|
|||
|
sorry, but your post does not make a lot of sense... try to explain a bit more in detail or post some code
|
|
#3
|
|||
|
|||
|
sorry for that.
Guess its because i barely understand it myself and my cracky english(from sweden) anyway heres some code witch illustrates the problem, but not in the same context as i described earlier. #include <iostream.h> class test { public: int func1(int n); int func2(int n); int func3(int n, int (*pt)(int n)); }; int test::func1(int n) { for(int i = 0; i<n;i++) cout << "1" << endl; return 0; } int test::func2(int n) { for(int i = 0; i<n; i++) cout << "2" << endl; return 0; } int test::func3(int n ,int (*pt)(int)) { pt(n); return 0; } int main() { test t; cout << "directly" << endl; t.func1(10); t.func2(10); cout << "throu funcptr" << endl; t.func3(10,t.func1); //gives: error C2664: 'test::func3' : cannot convert parameter 2 from 'int (int)' to 'int (__cdecl *)(int)' t.func3(10,t.func2); int i; cin >> i; } I would appreciate any help from anyone |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Function pointers in class defenition |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|