C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Overloades member function

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Krish
Guest





PostPosted: Thu Sep 30, 2004 2:38 am    Post subject: Overloades member function Reply with quote



Hi There,

I am having problem when I compile a code which I create to test a
source file. The errors are :
error C2144: syntax error : 'void' should be preceded by ';'
error C2511: 'void CNewServiceApp::function(SER,DWORD,LPVOID)' :
overloaded member function not found in 'CNewServiceApp'

Can someone help me to solve this?
Thanks,
Krish

HeaderFile
class CNewServiceApp : public CWinApp
{
public:
CNewServiceApp();

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNewServiceApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL

// Implementation
//func(int);
//func(this);

static DWORD CALLBACK function(CService*, DWORD, LPVOID);
DWORD function(CService*, DWORD);

LPVOID arg;

//{{AFX_MSG(CNewServiceApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CPP file:

BOOL CNewServiceApp::InitInstance()
{
AfxEnableControlContainer();

// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.

arg = this;

MyService = new CService("NewService",function, this );


return FALSE;

}



typedef CService SER
void CNewServiceApp::function(SER A, DWORD na, LPVOID arg)
{
CNewServiceApp *pCNewServiceApp;

if (arg == NULL)
{
return FALSE;
}

pCNewServiceApp = (CNewServiceApp*)arg;

return pCNewServiceApp ->function(A, arg);

}
Back to top
David Hilsee
Guest





PostPosted: Thu Sep 30, 2004 2:54 am    Post subject: Re: Overloades member function Reply with quote



"Krish" <krish_jasmin (AT) yahoo (DOT) ca> wrote

Quote:
Hi There,

I am having problem when I compile a code which I create to test a
source file. The errors are :
error C2144: syntax error : 'void' should be preceded by ';'
error C2511: 'void CNewServiceApp::function(SER,DWORD,LPVOID)' :
overloaded member function not found in 'CNewServiceApp'

Can someone help me to solve this?
Thanks,
Krish

HeaderFile
class CNewServiceApp : public CWinApp
{
public:
CNewServiceApp();

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNewServiceApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL

// Implementation
//func(int);
//func(this);

static DWORD CALLBACK function(CService*, DWORD, LPVOID);
DWORD function(CService*, DWORD);

LPVOID arg;

//{{AFX_MSG(CNewServiceApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CPP file:

BOOL CNewServiceApp::InitInstance()
{
AfxEnableControlContainer();

// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.

arg = this;

MyService = new CService("NewService",function, this );


return FALSE;

}



typedef CService SER
void CNewServiceApp::function(SER A, DWORD na, LPVOID arg)
{
CNewServiceApp *pCNewServiceApp;

if (arg == NULL)
{
return FALSE;
}

pCNewServiceApp = (CNewServiceApp*)arg;

return pCNewServiceApp ->function(A, arg);

}

I'm going to try to ignore all of the unexplained stuff that resembles MFC
and answer your questions as they pertain to the C++ language.

First of all, the line reading

typedef CService SER

needs a semicolon

typedef CService SER;

And, AFAICT, you were trying to declare and define a member function of
CNewServiceApp (CNewServiceApp::function) that takes a CService*, so
wouldn't you use

void CNewServiceApp::function(SER * A, DWORD na, LPVOID arg)

in the definition? After all, SER is a typedef for CService, not a pointer
to a CService. If I were you, I would move the typedef so I could use it in
both the declaration and the definition, but that's entirely up to you.

--
David Hilsee



Back to top
John Harrison
Guest





PostPosted: Thu Sep 30, 2004 6:14 am    Post subject: Re: Overloades member function Reply with quote




"David Hilsee" <davidhilseenews (AT) yahoo (DOT) com> wrote

Quote:
"Krish" <krish_jasmin (AT) yahoo (DOT) ca> wrote in message
news:b8dab48e.0409291838.79881242 (AT) posting (DOT) google.com...
Hi There,

First of all, the line reading

typedef CService SER

needs a semicolon

typedef CService SER;

And, AFAICT, you were trying to declare and define a member function of
CNewServiceApp (CNewServiceApp::function) that takes a CService*, so
wouldn't you use

void CNewServiceApp::function(SER * A, DWORD na, LPVOID arg)

in the definition? After all, SER is a typedef for CService, not a
pointer
to a CService. If I were you, I would move the typedef so I could use it
in
both the declaration and the definition, but that's entirely up to you.


If I were the OP I'd just remove the typedef entirely. After all what is the
point of

typedef CService SER;

Why not just use CService throughout and avoid confusing everybody
(including yourself).

john



Back to top
Krish
Guest





PostPosted: Thu Sep 30, 2004 11:45 am    Post subject: Re: Overloades member function Reply with quote

Thanks for you replies.

I have a question, if I have a global function that pointed to class
or object, then how do I pass arguments to that function.
I have CService *MyService; in my cpp
and in my header, i have
static DWORD CALLBACK function(CService*, DWORD, LPVOID);
DWORD func(CService*, DWORD);

then how do i pass argument for that pointer.
CNewServiceApp::function(-------, DWORD R, LPVOID arg);
what should I put in ----- above.

Krish


"John Harrison" <john_andronicus (AT) hotmail (DOT) com> wrote

Quote:
"David Hilsee" <davidhilseenews (AT) yahoo (DOT) com> wrote in message
news:96KdnTzz_NPO6MbcRVn-sA (AT) comcast (DOT) com...
"Krish" <krish_jasmin (AT) yahoo (DOT) ca> wrote in message
news:b8dab48e.0409291838.79881242 (AT) posting (DOT) google.com...
Hi There,

First of all, the line reading

typedef CService SER

needs a semicolon

typedef CService SER;

And, AFAICT, you were trying to declare and define a member function of
CNewServiceApp (CNewServiceApp::function) that takes a CService*, so
wouldn't you use

void CNewServiceApp::function(SER * A, DWORD na, LPVOID arg)

in the definition? After all, SER is a typedef for CService, not a
pointer
to a CService. If I were you, I would move the typedef so I could use it
in
both the declaration and the definition, but that's entirely up to you.


If I were the OP I'd just remove the typedef entirely. After all what is the
point of

typedef CService SER;

Why not just use CService throughout and avoid confusing everybody
(including yourself).

john

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.