from void (void*) to void (_cdecl*) (void*) 
Author Message
 from void (void*) to void (_cdecl*) (void*)

Hi Everybody,

Here's my problem:

I declared a pointer to a function that has one argument.
/////////////////
typedef void (*DELETE_FCT)(void* m_ptrContenu);
////////////////

And I used a class CJEListe

////////////////////////
class CJELListe
{
 public:

        // Constructeurs / destructeur
        CJELListe() ;
        CJELListe(const CJELListe& LSource) ;
        virtual ~CJELListe() ;

        // fonction de modification du contenu
        int    AjouterElement(void* pElement, DELETE_FCT
fnDeleteElement) ;
        int    InsererElement(long lPosition, void *pElement, DELETE_FCT
fnDeleteElement) ;
       ....

Quote:
};

////////////////////////

then I declared a template class that inherites from CJELListe

///////////////////////

template <class _T>
class CJELListeTypee : public CJELListe
{
 private:

   void DeleteType( void *pVar)

public:

  CJELListeTypee();
  CJELListeTypee(const CJELListeTypee<_T> & listeTypee);
   virtual ~CJELListeTypee();

   int   AjouterElement_T( const _T & templateElement) { return
CJELListe::AjouterElement( new _T(templateElement), DeleteType); }
   int   InsererElement_T(long lPosition, const _T & tempElment)      {
return CJELListe::InsererElement( lPosition, new (tempElment),
DeleteType ); }

  ....

Quote:
};

//////////////////

 In my main()

/////
void main()
{
    CJELListeTypee<int> listInt;
    int ia = 1;
    listInt.AjouterElement_T ( ia);

Quote:
}

////////////////

when compiling, I got this message : C:\Temp\testTypee\testTypee.cpp(70)
: error C2664: 'AjouterElement' : cannot convert parameter 2 from 'void
(void *)' to 'void (__cdecl *)(void *)'
        None of the functions with this name in scope match the target
type
        C:\Temp\testTypee\testTypee.cpp(135) : while compiling
class-template member function 'int __thiscall
CJELListeTypee<int>::AjouterElement_T(const class CJELElement_T<int> &)'

Error executing cl.exe.

How Have i to proceed to avoid this problem ? I don't have to modify
CJELListe because it isn't mine.

Thanks in advance,
best regards,

Mohamed BEN SLIMANE



Fri, 10 Oct 2003 16:57:30 GMT  
 from void (void*) to void (_cdecl*) (void*)
Your typedef is for a nonmember function. You try to pass a member function.

void (*T)(void*)

and

void (CJELListeTypee::*T)(void*)

are two different incompatible types, if only because member function
accepts one additional implicit parameter ('this' pointer of the instance of
the class).
--
With best wishes,
    Igor Tandetnik



Quote:
> Hi Everybody,

> Here's my problem:

> I declared a pointer to a function that has one argument.
> /////////////////
> typedef void (*DELETE_FCT)(void* m_ptrContenu);
> ////////////////

> And I used a class CJEListe

> ////////////////////////
> class CJELListe
> {
>  public:

>         // Constructeurs / destructeur
>         CJELListe() ;
>         CJELListe(const CJELListe& LSource) ;
>         virtual ~CJELListe() ;

>         // fonction de modification du contenu
>         int    AjouterElement(void* pElement, DELETE_FCT
> fnDeleteElement) ;
>         int    InsererElement(long lPosition, void *pElement, DELETE_FCT
> fnDeleteElement) ;
>        ....
> };
> ////////////////////////

> then I declared a template class that inherites from CJELListe

> ///////////////////////

> template <class _T>
> class CJELListeTypee : public CJELListe
> {
>  private:

>    void DeleteType( void *pVar)

> public:

>   CJELListeTypee();
>   CJELListeTypee(const CJELListeTypee<_T> & listeTypee);
>    virtual ~CJELListeTypee();

>    int   AjouterElement_T( const _T & templateElement) { return
> CJELListe::AjouterElement( new _T(templateElement), DeleteType); }
>    int   InsererElement_T(long lPosition, const _T & tempElment)      {
> return CJELListe::InsererElement( lPosition, new (tempElment),
> DeleteType ); }

>   ....

> };
> //////////////////

>  In my main()

> /////
> void main()
> {
>     CJELListeTypee<int> listInt;
>     int ia = 1;
>     listInt.AjouterElement_T ( ia);
> }
> ////////////////

> when compiling, I got this message : C:\Temp\testTypee\testTypee.cpp(70)
> : error C2664: 'AjouterElement' : cannot convert parameter 2 from 'void
> (void *)' to 'void (__cdecl *)(void *)'
>         None of the functions with this name in scope match the target
> type
>         C:\Temp\testTypee\testTypee.cpp(135) : while compiling
> class-template member function 'int __thiscall
> CJELListeTypee<int>::AjouterElement_T(const class CJELElement_T<int> &)'

> Error executing cl.exe.

> How Have i to proceed to avoid this problem ? I don't have to modify
> CJELListe because it isn't mine.

> Thanks in advance,
> best regards,

> Mohamed BEN SLIMANE



Sat, 11 Oct 2003 04:07:10 GMT  
 from void (void*) to void (_cdecl*) (void*)
Igor,

I moved my DeleteType Function from the class and changed it into

template <class _T>
void DeleteType( void * p)
{
 ....

Quote:
}

and i still have the same problem.

Could You help me to have this problem solved quickly please ?

Best regards,
Mohamed BEN SLIMANE

Igor Tandetnik a crit :

Quote:
> Your typedef is for a nonmember function. You try to pass a member function.

> void (*T)(void*)

> and

> void (CJELListeTypee::*T)(void*)

> are two different incompatible types, if only because member function
> accepts one additional implicit parameter ('this' pointer of the instance of
> the class).
> --
> With best wishes,
>     Igor Tandetnik



> > Hi Everybody,

> > Here's my problem:

> > I declared a pointer to a function that has one argument.
> > /////////////////
> > typedef void (*DELETE_FCT)(void* m_ptrContenu);
> > ////////////////

> > And I used a class CJEListe

> > ////////////////////////
> > class CJELListe
> > {
> >  public:

> >         // Constructeurs / destructeur
> >         CJELListe() ;
> >         CJELListe(const CJELListe& LSource) ;
> >         virtual ~CJELListe() ;

> >         // fonction de modification du contenu
> >         int    AjouterElement(void* pElement, DELETE_FCT
> > fnDeleteElement) ;
> >         int    InsererElement(long lPosition, void *pElement, DELETE_FCT
> > fnDeleteElement) ;
> >        ....
> > };
> > ////////////////////////

> > then I declared a template class that inherites from CJELListe

> > ///////////////////////

> > template <class _T>
> > class CJELListeTypee : public CJELListe
> > {
> >  private:

> >    void DeleteType( void *pVar)

> > public:

> >   CJELListeTypee();
> >   CJELListeTypee(const CJELListeTypee<_T> & listeTypee);
> >    virtual ~CJELListeTypee();

> >    int   AjouterElement_T( const _T & templateElement) { return
> > CJELListe::AjouterElement( new _T(templateElement), DeleteType); }
> >    int   InsererElement_T(long lPosition, const _T & tempElment)      {
> > return CJELListe::InsererElement( lPosition, new (tempElment),
> > DeleteType ); }

> >   ....

> > };
> > //////////////////

> >  In my main()

> > /////
> > void main()
> > {
> >     CJELListeTypee<int> listInt;
> >     int ia = 1;
> >     listInt.AjouterElement_T ( ia);
> > }
> > ////////////////

> > when compiling, I got this message : C:\Temp\testTypee\testTypee.cpp(70)
> > : error C2664: 'AjouterElement' : cannot convert parameter 2 from 'void
> > (void *)' to 'void (__cdecl *)(void *)'
> >         None of the functions with this name in scope match the target
> > type
> >         C:\Temp\testTypee\testTypee.cpp(135) : while compiling
> > class-template member function 'int __thiscall
> > CJELListeTypee<int>::AjouterElement_T(const class CJELElement_T<int> &)'

> > Error executing cl.exe.

> > How Have i to proceed to avoid this problem ? I don't have to modify
> > CJELListe because it isn't mine.

> > Thanks in advance,
> > best regards,

> > Mohamed BEN SLIMANE



Sat, 11 Oct 2003 20:18:05 GMT  
 from void (void*) to void (_cdecl*) (void*)
Greets,

    Currently, your code runs into a problem where your base class is
dependent upon function pointers to a templated class for which code has not
yet been generated.  You run into the problem where you need to specify the
templated function member pointer in the base class which cannot yet see the
template class; the templated class cannot derive from the base because it
has not yet been declared.  Your code is a good candidate for providing a
virtual override, in which you make DeleteType() a virtual member of the
CJELListe base class, and then override in your templated derived class.  In
this case, there is no need to pass the function pointer for the various
members, instead, you can take a pointer to the base class and the compiler
will ensure the appropriate DeleteType() is called.

Regards,

Joe



Quote:
> Igor,

> I moved my DeleteType Function from the class and changed it into

> template <class _T>
> void DeleteType( void * p)
> {
>  ....
> }

> and i still have the same problem.

> Could You help me to have this problem solved quickly please ?

> Best regards,
> Mohamed BEN SLIMANE

> Igor Tandetnik a crit :

> > Your typedef is for a nonmember function. You try to pass a member
function.

> > void (*T)(void*)

> > and

> > void (CJELListeTypee::*T)(void*)

> > are two different incompatible types, if only because member function
> > accepts one additional implicit parameter ('this' pointer of the
instance of
> > the class).
> > --
> > With best wishes,
> >     Igor Tandetnik


message

> > > Hi Everybody,

> > > Here's my problem:

> > > I declared a pointer to a function that has one argument.
> > > /////////////////
> > > typedef void (*DELETE_FCT)(void* m_ptrContenu);
> > > ////////////////

> > > And I used a class CJEListe

> > > ////////////////////////
> > > class CJELListe
> > > {
> > >  public:

> > >         // Constructeurs / destructeur
> > >         CJELListe() ;
> > >         CJELListe(const CJELListe& LSource) ;
> > >         virtual ~CJELListe() ;

> > >         // fonction de modification du contenu
> > >         int    AjouterElement(void* pElement, DELETE_FCT
> > > fnDeleteElement) ;
> > >         int    InsererElement(long lPosition, void *pElement,
DELETE_FCT
> > > fnDeleteElement) ;
> > >        ....
> > > };
> > > ////////////////////////

> > > then I declared a template class that inherites from CJELListe

> > > ///////////////////////

> > > template <class _T>
> > > class CJELListeTypee : public CJELListe
> > > {
> > >  private:

> > >    void DeleteType( void *pVar)

> > > public:

> > >   CJELListeTypee();
> > >   CJELListeTypee(const CJELListeTypee<_T> & listeTypee);
> > >    virtual ~CJELListeTypee();

> > >    int   AjouterElement_T( const _T & templateElement) { return
> > > CJELListe::AjouterElement( new _T(templateElement), DeleteType); }
> > >    int   InsererElement_T(long lPosition, const _T & tempElment)
{
> > > return CJELListe::InsererElement( lPosition, new (tempElment),
> > > DeleteType ); }

> > >   ....

> > > };
> > > //////////////////

> > >  In my main()

> > > /////
> > > void main()
> > > {
> > >     CJELListeTypee<int> listInt;
> > >     int ia = 1;
> > >     listInt.AjouterElement_T ( ia);
> > > }
> > > ////////////////

> > > when compiling, I got this message :

C:\Temp\testTypee\testTypee.cpp(70)

- Show quoted text -

Quote:
> > > : error C2664: 'AjouterElement' : cannot convert parameter 2 from
'void
> > > (void *)' to 'void (__cdecl *)(void *)'
> > >         None of the functions with this name in scope match the target
> > > type
> > >         C:\Temp\testTypee\testTypee.cpp(135) : while compiling
> > > class-template member function 'int __thiscall
> > > CJELListeTypee<int>::AjouterElement_T(const class CJELElement_T<int>
&)'

> > > Error executing cl.exe.

> > > How Have i to proceed to avoid this problem ? I don't have to modify
> > > CJELListe because it isn't mine.

> > > Thanks in advance,
> > > best regards,

> > > Mohamed BEN SLIMANE



Sat, 11 Oct 2003 20:36:51 GMT  
 from void (void*) to void (_cdecl*) (void*)
Thanks Joe for your answer. It does work :))

Best regards,
Mohamed BEN SLIMANE

Joe Delekto a crit :

Quote:
> Greets,

>     Currently, your code runs into a problem where your base class is
> dependent upon function pointers to a templated class for which code has not
> yet been generated.  You run into the problem where you need to specify the
> templated function member pointer in the base class which cannot yet see the
> template class; the templated class cannot derive from the base because it
> has not yet been declared.  Your code is a good candidate for providing a
> virtual override, in which you make DeleteType() a virtual member of the
> CJELListe base class, and then override in your templated derived class.  In
> this case, there is no need to pass the function pointer for the various
> members, instead, you can take a pointer to the base class and the compiler
> will ensure the appropriate DeleteType() is called.

> Regards,

> Joe



> > Igor,

> > I moved my DeleteType Function from the class and changed it into

> > template <class _T>
> > void DeleteType( void * p)
> > {
> >  ....
> > }

> > and i still have the same problem.

> > Could You help me to have this problem solved quickly please ?

> > Best regards,
> > Mohamed BEN SLIMANE

> > Igor Tandetnik a crit :

> > > Your typedef is for a nonmember function. You try to pass a member
> function.

> > > void (*T)(void*)

> > > and

> > > void (CJELListeTypee::*T)(void*)

> > > are two different incompatible types, if only because member function
> > > accepts one additional implicit parameter ('this' pointer of the
> instance of
> > > the class).
> > > --
> > > With best wishes,
> > >     Igor Tandetnik


> message

> > > > Hi Everybody,

> > > > Here's my problem:

> > > > I declared a pointer to a function that has one argument.
> > > > /////////////////
> > > > typedef void (*DELETE_FCT)(void* m_ptrContenu);
> > > > ////////////////

> > > > And I used a class CJEListe

> > > > ////////////////////////
> > > > class CJELListe
> > > > {
> > > >  public:

> > > >         // Constructeurs / destructeur
> > > >         CJELListe() ;
> > > >         CJELListe(const CJELListe& LSource) ;
> > > >         virtual ~CJELListe() ;

> > > >         // fonction de modification du contenu
> > > >         int    AjouterElement(void* pElement, DELETE_FCT
> > > > fnDeleteElement) ;
> > > >         int    InsererElement(long lPosition, void *pElement,
> DELETE_FCT
> > > > fnDeleteElement) ;
> > > >        ....
> > > > };
> > > > ////////////////////////

> > > > then I declared a template class that inherites from CJELListe

> > > > ///////////////////////

> > > > template <class _T>
> > > > class CJELListeTypee : public CJELListe
> > > > {
> > > >  private:

> > > >    void DeleteType( void *pVar)

> > > > public:

> > > >   CJELListeTypee();
> > > >   CJELListeTypee(const CJELListeTypee<_T> & listeTypee);
> > > >    virtual ~CJELListeTypee();

> > > >    int   AjouterElement_T( const _T & templateElement) { return
> > > > CJELListe::AjouterElement( new _T(templateElement), DeleteType); }
> > > >    int   InsererElement_T(long lPosition, const _T & tempElment)
> {
> > > > return CJELListe::InsererElement( lPosition, new (tempElment),
> > > > DeleteType ); }

> > > >   ....

> > > > };
> > > > //////////////////

> > > >  In my main()

> > > > /////
> > > > void main()
> > > > {
> > > >     CJELListeTypee<int> listInt;
> > > >     int ia = 1;
> > > >     listInt.AjouterElement_T ( ia);
> > > > }
> > > > ////////////////

> > > > when compiling, I got this message :
> C:\Temp\testTypee\testTypee.cpp(70)
> > > > : error C2664: 'AjouterElement' : cannot convert parameter 2 from
> 'void
> > > > (void *)' to 'void (__cdecl *)(void *)'
> > > >         None of the functions with this name in scope match the target
> > > > type
> > > >         C:\Temp\testTypee\testTypee.cpp(135) : while compiling
> > > > class-template member function 'int __thiscall
> > > > CJELListeTypee<int>::AjouterElement_T(const class CJELElement_T<int>
> &)'

> > > > Error executing cl.exe.

> > > > How Have i to proceed to avoid this problem ? I don't have to modify
> > > > CJELListe because it isn't mine.

> > > > Thanks in advance,
> > > > best regards,

> > > > Mohamed BEN SLIMANE



Sat, 11 Oct 2003 22:48:21 GMT  
 from void (void*) to void (_cdecl*) (void*)
Thanks Joe for your answer. It does work :))

Best regards,
Mohamed BEN SLIMANE

Joe Delekto a crit :

Quote:
> Greets,

>     Currently, your code runs into a problem where your base class is
> dependent upon function pointers to a templated class for which code has not
> yet been generated.  You run into the problem where you need to specify the
> templated function member pointer in the base class which cannot yet see the
> template class; the templated class cannot derive from the base because it
> has not yet been declared.  Your code is a good candidate for providing a
> virtual override, in which you make DeleteType() a virtual member of the
> CJELListe base class, and then override in your templated derived class.  In
> this case, there is no need to pass the function pointer for the various
> members, instead, you can take a pointer to the base class and the compiler
> will ensure the appropriate DeleteType() is called.

> Regards,

> Joe



> > Igor,

> > I moved my DeleteType Function from the class and changed it into

> > template <class _T>
> > void DeleteType( void * p)
> > {
> >  ....
> > }

> > and i still have the same problem.

> > Could You help me to have this problem solved quickly please ?

> > Best regards,
> > Mohamed BEN SLIMANE

> > Igor Tandetnik a crit :

> > > Your typedef is for a nonmember function. You try to pass a member
> function.

> > > void (*T)(void*)

> > > and

> > > void (CJELListeTypee::*T)(void*)

> > > are two different incompatible types, if only because member function
> > > accepts one additional implicit parameter ('this' pointer of the
> instance of
> > > the class).
> > > --
> > > With best wishes,
> > >     Igor Tandetnik


> message

> > > > Hi Everybody,

> > > > Here's my problem:

> > > > I declared a pointer to a function that has one argument.
> > > > /////////////////
> > > > typedef void (*DELETE_FCT)(void* m_ptrContenu);
> > > > ////////////////

> > > > And I used a class CJEListe

> > > > ////////////////////////
> > > > class CJELListe
> > > > {
> > > >  public:

> > > >         // Constructeurs / destructeur
> > > >         CJELListe() ;
> > > >         CJELListe(const CJELListe& LSource) ;
> > > >         virtual ~CJELListe() ;

> > > >         // fonction de modification du contenu
> > > >         int    AjouterElement(void* pElement, DELETE_FCT
> > > > fnDeleteElement) ;
> > > >         int    InsererElement(long lPosition, void *pElement,
> DELETE_FCT
> > > > fnDeleteElement) ;
> > > >        ....
> > > > };
> > > > ////////////////////////

> > > > then I declared a template class that inherites from CJELListe

> > > > ///////////////////////

> > > > template <class _T>
> > > > class CJELListeTypee : public CJELListe
> > > > {
> > > >  private:

> > > >    void DeleteType( void *pVar)

> > > > public:

> > > >   CJELListeTypee();
> > > >   CJELListeTypee(const CJELListeTypee<_T> & listeTypee);
> > > >    virtual ~CJELListeTypee();

> > > >    int   AjouterElement_T( const _T & templateElement) { return
> > > > CJELListe::AjouterElement( new _T(templateElement), DeleteType); }
> > > >    int   InsererElement_T(long lPosition, const _T & tempElment)
> {
> > > > return CJELListe::InsererElement( lPosition, new (tempElment),
> > > > DeleteType ); }

> > > >   ....

> > > > };
> > > > //////////////////

> > > >  In my main()

> > > > /////
> > > > void main()
> > > > {
> > > >     CJELListeTypee<int> listInt;
> > > >     int ia = 1;
> > > >     listInt.AjouterElement_T ( ia);
> > > > }
> > > > ////////////////

> > > > when compiling, I got this message :
> C:\Temp\testTypee\testTypee.cpp(70)
> > > > : error C2664: 'AjouterElement' : cannot convert parameter 2 from
> 'void
> > > > (void *)' to 'void (__cdecl *)(void *)'
> > > >         None of the functions with this name in scope match the target
> > > > type
> > > >         C:\Temp\testTypee\testTypee.cpp(135) : while compiling
> > > > class-template member function 'int __thiscall
> > > > CJELListeTypee<int>::AjouterElement_T(const class CJELElement_T<int>
> &)'

> > > > Error executing cl.exe.

> > > > How Have i to proceed to avoid this problem ? I don't have to modify
> > > > CJELListe because it isn't mine.

> > > > Thanks in advance,
> > > > best regards,

> > > > Mohamed BEN SLIMANE



Sat, 11 Oct 2003 22:51:49 GMT  
 from void (void*) to void (_cdecl*) (void*)
Thanks Joe for your answer. It does work :))

Best regards,
Mohamed BEN SLIMANE

Joe Delekto a crit :

Quote:
> Greets,

>     Currently, your code runs into a problem where your base class is
> dependent upon function pointers to a templated class for which code has not
> yet been generated.  You run into the problem where you need to specify the
> templated function member pointer in the base class which cannot yet see the
> template class; the templated class cannot derive from the base because it
> has not yet been declared.  Your code is a good candidate for providing a
> virtual override, in which you make DeleteType() a virtual member of the
> CJELListe base class, and then override in your templated derived class.  In
> this case, there is no need to pass the function pointer for the various
> members, instead, you can take a pointer to the base class and the compiler
> will ensure the appropriate DeleteType() is called.

> Regards,

> Joe



> > Igor,

> > I moved my DeleteType Function from the class and changed it into

> > template <class _T>
> > void DeleteType( void * p)
> > {
> >  ....
> > }

> > and i still have the same problem.

> > Could You help me to have this problem solved quickly please ?

> > Best regards,
> > Mohamed BEN SLIMANE

> > Igor Tandetnik a crit :

> > > Your typedef is for a nonmember function. You try to pass a member
> function.

> > > void (*T)(void*)

> > > and

> > > void (CJELListeTypee::*T)(void*)

> > > are two different incompatible types, if only because member function
> > > accepts one additional implicit parameter ('this' pointer of the
> instance of
> > > the class).
> > > --
> > > With best wishes,
> > >     Igor Tandetnik


> message

> > > > Hi Everybody,

> > > > Here's my problem:

> > > > I declared a pointer to a function that has one argument.
> > > > /////////////////
> > > > typedef void (*DELETE_FCT)(void* m_ptrContenu);
> > > > ////////////////

> > > > And I used a class CJEListe

> > > > ////////////////////////
> > > > class CJELListe
> > > > {
> > > >  public:

> > > >         // Constructeurs / destructeur
> > > >         CJELListe() ;
> > > >         CJELListe(const CJELListe& LSource) ;
> > > >         virtual ~CJELListe() ;

> > > >         // fonction de modification du contenu
> > > >         int    AjouterElement(void* pElement, DELETE_FCT
> > > > fnDeleteElement) ;
> > > >         int    InsererElement(long lPosition, void *pElement,
> DELETE_FCT
> > > > fnDeleteElement) ;
> > > >        ....
> > > > };
> > > > ////////////////////////

> > > > then I declared a template class that inherites from CJELListe

> > > > ///////////////////////

> > > > template <class _T>
> > > > class CJELListeTypee : public CJELListe
> > > > {
> > > >  private:

> > > >    void DeleteType( void *pVar)

> > > > public:

> > > >   CJELListeTypee();
> > > >   CJELListeTypee(const CJELListeTypee<_T> & listeTypee);
> > > >    virtual ~CJELListeTypee();

> > > >    int   AjouterElement_T( const _T & templateElement) { return
> > > > CJELListe::AjouterElement( new _T(templateElement), DeleteType); }
> > > >    int   InsererElement_T(long lPosition, const _T & tempElment)
> {
> > > > return CJELListe::InsererElement( lPosition, new (tempElment),
> > > > DeleteType ); }

> > > >   ....

> > > > };
> > > > //////////////////

> > > >  In my main()

> > > > /////
> > > > void main()
> > > > {
> > > >     CJELListeTypee<int> listInt;
> > > >     int ia = 1;
> > > >     listInt.AjouterElement_T ( ia);
> > > > }
> > > > ////////////////

> > > > when compiling, I got this message :
> C:\Temp\testTypee\testTypee.cpp(70)
> > > > : error C2664: 'AjouterElement' : cannot convert parameter 2 from
> 'void
> > > > (void *)' to 'void (__cdecl *)(void *)'
> > > >         None of the functions with this name in scope match the target
> > > > type
> > > >         C:\Temp\testTypee\testTypee.cpp(135) : while compiling
> > > > class-template member function 'int __thiscall
> > > > CJELListeTypee<int>::AjouterElement_T(const class CJELElement_T<int>
> &)'

> > > > Error executing cl.exe.

> > > > How Have i to proceed to avoid this problem ? I don't have to modify
> > > > CJELListe because it isn't mine.

> > > > Thanks in advance,
> > > > best regards,

> > > > Mohamed BEN SLIMANE



Sat, 11 Oct 2003 22:50:15 GMT  
 from void (void*) to void (_cdecl*) (void*)
Thanks Joe for your answer. It does work :))

Best regards,
Mohamed BEN SLIMANE

Joe Delekto a crit :

Quote:
> Greets,

>     Currently, your code runs into a problem where your base class is
> dependent upon function pointers to a templated class for which code has not
> yet been generated.  You run into the problem where you need to specify the
> templated function member pointer in the base class which cannot yet see the
> template class; the templated class cannot derive from the base because it
> has not yet been declared.  Your code is a good candidate for providing a
> virtual override, in which you make DeleteType() a virtual member of the
> CJELListe base class, and then override in your templated derived class.  In
> this case, there is no need to pass the function pointer for the various
> members, instead, you can take a pointer to the base class and the compiler
> will ensure the appropriate DeleteType() is called.

> Regards,

> Joe



> > Igor,

> > I moved my DeleteType Function from the class and changed it into

> > template <class _T>
> > void DeleteType( void * p)
> > {
> >  ....
> > }

> > and i still have the same problem.

> > Could You help me to have this problem solved quickly please ?

> > Best regards,
> > Mohamed BEN SLIMANE

> > Igor Tandetnik a crit :

> > > Your typedef is for a nonmember function. You try to pass a member
> function.

> > > void (*T)(void*)

> > > and

> > > void (CJELListeTypee::*T)(void*)

> > > are two different incompatible types, if only because member function
> > > accepts one additional implicit parameter ('this' pointer of the
> instance of
> > > the class).
> > > --
> > > With best wishes,
> > >     Igor Tandetnik


> message

> > > > Hi Everybody,

> > > > Here's my problem:

> > > > I declared a pointer to a function that has one argument.
> > > > /////////////////
> > > > typedef void (*DELETE_FCT)(void* m_ptrContenu);
> > > > ////////////////

> > > > And I used a class CJEListe

> > > > ////////////////////////
> > > > class CJELListe
> > > > {
> > > >  public:

> > > >         // Constructeurs / destructeur
> > > >         CJELListe() ;
> > > >         CJELListe(const CJELListe& LSource) ;
> > > >         virtual ~CJELListe() ;

> > > >         // fonction de modification du contenu
> > > >         int    AjouterElement(void* pElement, DELETE_FCT
> > > > fnDeleteElement) ;
> > > >         int    InsererElement(long lPosition, void *pElement,
> DELETE_FCT
> > > > fnDeleteElement) ;
> > > >        ....
> > > > };
> > > > ////////////////////////

> > > > then I declared a template class that inherites from CJELListe

> > > > ///////////////////////

> > > > template <class _T>
> > > > class CJELListeTypee : public CJELListe
> > > > {
> > > >  private:

> > > >    void DeleteType( void *pVar)

> > > > public:

> > > >   CJELListeTypee();
> > > >   CJELListeTypee(const CJELListeTypee<_T> & listeTypee);
> > > >    virtual ~CJELListeTypee();

> > > >    int   AjouterElement_T( const _T & templateElement) { return
> > > > CJELListe::AjouterElement( new _T(templateElement), DeleteType); }
> > > >    int   InsererElement_T(long lPosition, const _T & tempElment)
> {
> > > > return CJELListe::InsererElement( lPosition, new (tempElment),
> > > > DeleteType ); }

> > > >   ....

> > > > };
> > > > //////////////////

> > > >  In my main()

> > > > /////
> > > > void main()
> > > > {
> > > >     CJELListeTypee<int> listInt;
> > > >     int ia = 1;
> > > >     listInt.AjouterElement_T ( ia);
> > > > }
> > > > ////////////////

> > > > when compiling, I got this message :
> C:\Temp\testTypee\testTypee.cpp(70)
> > > > : error C2664: 'AjouterElement' : cannot convert parameter 2 from
> 'void
> > > > (void *)' to 'void (__cdecl *)(void *)'
> > > >         None of the functions with this name in scope match the target
> > > > type
> > > >         C:\Temp\testTypee\testTypee.cpp(135) : while compiling
> > > > class-template member function 'int __thiscall
> > > > CJELListeTypee<int>::AjouterElement_T(const class CJELElement_T<int>
> &)'

> > > > Error executing cl.exe.

> > > > How Have i to proceed to avoid this problem ? I don't have to modify
> > > > CJELListe because it isn't mine.

> > > > Thanks in advance,
> > > > best regards,

> > > > Mohamed BEN SLIMANE



Sat, 11 Oct 2003 22:56:16 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. what's the difference between void main(void) and int main(void)

2. difference between void foo(void) and void foo()

3. typedef int COMPARE(const void *, const void *);

4. difference between void and <bold>void

5. void * & void

6. typedef void PF(int, void *);

7. Purpose of void main (void) and Functions

8. passing void func(void *) to a function

9. Is void main(void) a standard or not?

10. void ** v. void*

11. void main(void) ????

12. ok...what about void function(void)

 

 
Powered by phpBB® Forum Software