Results 1 to 2 of 2

Thread: [RESOLVED] calling a template funct from a template

  1. #1
    bob323
    Guest

    Resolved [RESOLVED] calling a template funct from a template

    Templates are kinda new to me I want to call a class template function from another class template function... here is what I mean.

    template <class T>
    void CPie::SetInitVect(T, const int dev){
    int val;
    ....
    SetSections(T,val);
    }

    template <class T>
    void CPie::SetSections(T,int size){
    }

    can't do this though.... gets mad about the T in the call
    : error C2275: 'T' : illegal use of this type as an expression

    any ideas??

  2. #2
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    The template T just tells you the type, it doesnt tell you the object.

    I think ur looking for:

    Code:
    template <class T>
    void CPie::SetInitVect(const T& dev)
    {
    	T val;
    	....
    	SetSections(val);
    }
    
    template <class T>
    void CPie::SetSections(T& size)
    {
    }
    Remember to reference the variable because you dont want to send a copy of the entire object to the function.
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

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