General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 24th, 2003, 06:58 AM
mmhodo mmhodo is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Sweden
Posts: 3 mmhodo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Function pointers in class defenition

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

Reply With Quote
  #2  
Old February 24th, 2003, 03:40 PM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
sorry, but your post does not make a lot of sense... try to explain a bit more in detail or post some code

Reply With Quote
  #3  
Old February 24th, 2003, 05:32 PM
mmhodo mmhodo is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Sweden
Posts: 3 mmhodo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Function pointers in class defenition


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT