CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Location
    SJCampos - SP - Brazil
    Posts
    30

    Question Using an template instance as a private member of a manged class. Is it possible?

    I would like to use a template class instance as a private member of a Managed Class. Is it possible?

    I´ve tried this on my managed class:
    Code:
    // PDAManager.h
    
    #include "lista.h" 
    
    
    	public __gc class PDAManager
    	{
    	private:
    		Lista <int> ListaDeInteiros;
    I have an unmanaged code that implements the template

    Code:
    //lista.h
    
    #pragma unmanaged
    
    template <class Classe2>
    class Lista
    {
    	protected:
    
    		Celula<Classe2>		sCabeca, sFinal, *pPonteiro;
    		int					      iTamanho;
    
    	public:
    
    		Celula<Classe2>		*pPont, *pPont1, *pPont2, *pPont3;
    
    		Lista		();
    		//.Lista		(Lista<Classe> &l);
    		//.~Lista	();
    //...
    }
    
    template <class Classe2>
    Lista<Classe2>::Lista()
    {
    	sCabeca.suc = &sFinal;
    	sCabeca.ant = &sCabeca;
    	sFinal.suc 	= &sFinal;
    	sFinal.ant 	= &sCabeca;
    	pPonteiro	= &sFinal;
    	iTamanho = 0;
    }
    I got this compiler error: Error C3633.

    Compiling...
    PDAManager.cpp
    c:\MyWorks\PDAManager.Net\PDAManager.h(72) : error C3633: cannot define 'ListaDeInteiros' as a member of managed 'IEAv::PDAManager'
    because of the presence of default constructor 'Lista<Classe2>::Lista' on class 'Lista<Classe2>'
    with
    [
    Classe2=int
    ]
    and
    [
    Classe2=int
    ]
    and
    [
    Classe2=int
    ]
    c:\MyWorks\PDAManager.Net\PDAIncludes\LISTA.H(56) : see declaration of 'Lista<Classe2>::Lista'
    with
    [
    Classe2=int
    ]
    and
    [
    Classe2=int
    ]
    What this Error C3633 means???

    What is Interesting that if I take out the constructor and destructor of the template class, the error disapear...

    I have attached the managed class and the templates classes that I am using. PDAManager.h has the Managed class that uses a template unmanaged class. Lista.h has the class that is an unmanaged template class.
    Attached Files Attached Files
    Last edited by Eliseu_CEL; January 13th, 2006 at 02:09 PM. Reason: I've given the wrong message error. improve the code example.
    Eliseu M. Gomes

    [email protected]

  2. #2
    Join Date
    Dec 2005
    Location
    SJCampos - SP - Brazil
    Posts
    30

    Unhappy Re: Using an template instance as a private member of a manged class. Is it possible?

    What is interesting is that I can use templates on a implementation of an method on the managed class (PdaManager).

    This code has compiled all right. No Problem at all!

    See:

    Code:
    void PDAManager::teste(){
    	ConjuntoDePonteiros<Objeto> cnjRadar; 
    	Radar* umRadar = new Radar();
    
    
    	cnjRadar.Inserir( umRadar );
    }
    Last edited by Eliseu_CEL; January 13th, 2006 at 02:10 PM.
    Eliseu M. Gomes

    [email protected]

  3. #3
    Join Date
    Dec 2005
    Location
    SJCampos - SP - Brazil
    Posts
    30

    Talking Re: Using an template instance as a private member of a manged class. Is it possible?

    I have simplified my code above, than you guys can understand easier.
    Eliseu M. Gomes

    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured