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

Thread: Passing Templates through Pointers

  1. #1
    Join Date
    May 2009

    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,
    template<class T>
    class List
    		T* Arg1;
    		List(T* first){Arg1=first;}
    Which I run through,
    void GetChildren(ListProperties &properties)
    	List<CPtrList> *list = new List<CPtrList>(properties.children);
    	int count = list->Arg1->GetCount();
    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.

  2. #2
    Join Date
    Apr 1999

    Re: Passing Templates through Pointers

    Can anyone shed some light on where the problem might be?
    Post a complete program, including the main() driver program that duplicates the error.

    What is ListProperties? What is it's value (it could be invalid)? When, where, and how is this code called? All of these things are not known with the code you posted.


    Paul McKenzie

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)