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?
Re: Passing Templates through Pointers
Quote:
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.
Regards,
Paul McKenzie