illegal call of non-static member function 
Author Message
 illegal call of non-static member function

hi,
   A  MFC AppWizard(exe) project , I new a dialog(mydialog).
   on mydialog.h, I add a new class

   class CTransfer : public CObject
        {
             private:
            char *inString;
            char *mny_in;
            char *mny_out;

        public:
        void myTransfer(char *mny_in, char *mny_out);
        };

  on mydialog.cpp,i write this
      void CTransfer::myTransfer(char *mny_in, char *mny_out)
            {

        xxxx;
            }
and
    on mydialog.cpp
void CCutDlg::OnOK()
{
        // TODO: Add extra validation here
        char *temp;
        char *s="1111";
        // TODO: Add your control notification handler code here
        CTransfer::myTransfer(s,temp);
        MessageBox(temp,"Reault",MB_OK);
        CDialog::OnOK();

Quote:
}

Press F7
  I GET ERROR
error C2352: 'CTransfer::myTransfer' : illegal call of non-static
member function

Thanks in advance!



Fri, 01 Nov 2002 03:00:00 GMT  
 illegal call of non-static member function
Hello,

(1) You have to create CTransfer object to do myTransfer, if you don't
define it as static method.
(2) You have to prealloc the temp to get the result returned. (good
style: call by reference)

void CCutDlg::OnOK()
{
        // TODO: Add extra validation here

        char temp[1024];
        char *s="1111";
        // TODO: Add your control notification handler code here
        CTransfer aTransferObj;
        aTransferObj.myTransfer(s, temp);
        MessageBox(temp,"Reault",MB_OK);

        CDialog::OnOK();

Quote:
}

Kang Xu
Quote:

> hi,
>    A  MFC AppWizard(exe) project , I new a dialog(mydialog).
>    on mydialog.h, I add a new class

>    class CTransfer : public CObject
>         {
>              private:
>             char *inString;
>             char *mny_in;
>             char *mny_out;

>         public:
>         void myTransfer(char *mny_in, char *mny_out);
>         };

>   on mydialog.cpp,i write this
>       void CTransfer::myTransfer(char *mny_in, char *mny_out)
>             {

>         xxxx;
>             }
> and
>     on mydialog.cpp
> void CCutDlg::OnOK()
> {
>         // TODO: Add extra validation here
>         char *temp;
>         char *s="1111";
>         // TODO: Add your control notification handler code here
>         CTransfer::myTransfer(s,temp);
>         MessageBox(temp,"Reault",MB_OK);
>         CDialog::OnOK();
> }
> Press F7
>   I GET ERROR
> error C2352: 'CTransfer::myTransfer' : illegal call of non-static
> member function

> Thanks in advance!



Fri, 01 Nov 2002 03:00:00 GMT  
 illegal call of non-static member function

Quote:
>    char *temp;
>    char *s="1111";
>    // TODO: Add your control notification handler code here
>    CTransfer::myTransfer(s,temp);
>  I GET ERROR
>error C2352: 'CTransfer::myTransfer' : illegal call of non-static
>member function

Yes, that's entirely right from the code you've shown - since that
function isn't a static method of your class.

You probably need to do this:

        CTransfer trans;

        /* Initialise your trans object */

        trans.myTransfer(...)

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Fri, 01 Nov 2002 03:00:00 GMT  
 illegal call of non-static member function

Quote:

>void CCutDlg::OnOK()
>{
>    // TODO: Add extra validation here
>    char *temp;
>    char *s="1111";
>    // TODO: Add your control notification handler code here
>    CTransfer::myTransfer(s,temp);
>    MessageBox(temp,"Reault",MB_OK);
>    CDialog::OnOK();
>}

Thanks both!


Sat, 02 Nov 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. illegal call of non-static member function

2. illegal call of non-static member function *HELP*

3. illegal call of non-static member function

4. Illegal call of non-static member function (error)?

5. illegal call of non-static member function

6. Error C2352 - illegal call of non-static member function

7. Compiler Error C2352: illegal call of non-static member function

8. illegal call of non-static member function

9. Nothing declared as static but: illegal call of non-static member function...

10. "illegal call of non-static member function"

11. CWnd::GetClientRect' : illegal call of non-static member function

12. Compiler Error C2352:<Function_Name> illegal call of non-static member function

 

 
Powered by phpBB® Forum Software