CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    May 2009
    Posts
    1

    Passing Templates through Pointers

    I'm having an issue with passing templates through pointers, I managed to simplify the issue to this.

    So I have a simple template,
    Code:
    template<class T>
    class List
    {
    	public:
    		T* Arg1;
    		List(T* first){Arg1=first;}
    };
    Which I run through,
    Code:
    void GetChildren(ListProperties &properties)
    {
    	List<CPtrList> *list = new List<CPtrList>(properties.children);
    	int count = list->Arg1->GetCount();
            Test(list);
    }
    
    void Test(void *list)
    {
    	List<CPtrList>* newList = (List<CPtrList>*)list;
            int count = newList->Arg1->GetCount();
    }
    The count in GetChildren gets me 1(the correct result), whereas the count in Test gets me a number that's way off (-45030200 or something along those lines).

    Can anyone shed some light on where the problem might be?
    Last edited by starbucks99; May 14th, 2009 at 09:48 AM.

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