Ask Function problem?thanks

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2006
Posts: 14
Reputation: rxgmoral is an unknown quantity at this point 
Solved Threads: 0
rxgmoral rxgmoral is offline Offline
Newbie Poster

Ask Function problem?thanks

 
0
  #1
Aug 3rd, 2006
Ask Function problem?thanks
<<<<<<<<<<Class.h>>>>>>>>>>
  1. #pragma once
  2. class Class
  3. {
  4. public:
  5. int get_return(int a,int b,int (*compare)());
  6. int Rxgmoral(int a,int b);
  7. void Fun();
  8. };
<<<<<<<<<Class.Cpp>>>>>>>>
  1. #include "Stdafx.h"
  2. #include "Class.h"
  3. int Class::get_return(int a,int b,int(* compare)())
  4. {
  5. return (compare(a,b));
  6. }
  7. int Class::Rxgmoral(int a, int b)
  8. {
  9. return a+b;
  10. }
  11. void Class::Fun()
  12. {
  13. int a;
  14. a=get_return(1,2,&Rxgmoral);
  15. }
  1. error:
  2. e:\mystudio\project\test\test\class.cpp(6) : error C2197: 'int (__cdecl *)(void)' : too many arguments for call
  3. e:\mystudio\project\test\test\class.cpp(17) : error C2276: '&' : illegal operation on bound member function expression
thanks
Last edited by WolfPack; Aug 3rd, 2006 at 7:27 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: Ask Function problem?thanks

 
0
  #2
Aug 3rd, 2006
try this
<<<<<<<<<<Class.h>>>>>>>>>>
 #pragma once
class Class
{
public:
    int get_return(int a,int b,int (*compare)(int, int));
    int Rxgmoral(int a,int b);
    void Fun();
};
<<<<<<<<<Class.Cpp>>>>>>>>
 #include "Stdafx.h"
#include "Class.h"
int Class::get_return(int a,int b,int(* compare)(int, int))
{
    return (compare(a,b));
}
int Class::Rxgmoral(int a, int b)
{
    return a+b;
}
void Class::Fun()
{
    int a;
    a=get_return(1,2,Rxgmoral);
}
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: Ask Function problem?thanks

 
0
  #3
Aug 3rd, 2006
Missed another one. You can't call non-static member functions like that. So change it to static.
<<<<<<<<<<Class.h>>>>>>>>>>
 #pragma once
class Class
{
public:
    int get_return(int a,int b,int (*compare)(int, int));
    static int Rxgmoral(int a,int b);
    void Fun();
};
<<<<<<<<<Class.Cpp>>>>>>>>
 #include "Stdafx.h"
#include "Class.h"
int Class::get_return(int a,int b,int(* compare)(int, int))
{
    return (compare(a,b));
}
int Class::Rxgmoral(int a, int b)
{
    return a+b;
}
void Class::Fun()
{
    int a;
    a=get_return(1,2,Class::Rxgmoral);
}
Last edited by WolfPack; Aug 3rd, 2006 at 7:48 am.
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 14
Reputation: rxgmoral is an unknown quantity at this point 
Solved Threads: 0
rxgmoral rxgmoral is offline Offline
Newbie Poster

Re: Ask Function problem?thanks

 
0
  #4
Aug 3rd, 2006
thank you help
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1611 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC