Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a pointer to a class using template

Status
Not open for further replies.

Weber1

Programmer
Sep 9, 2000
20
US
Can anyone please tell me how to create a pointer to a class that is using a template? My C++ book does not show an example of this and the compiler is having fits over it. I believe the syntax should be something like:

CLASSNAME<PARAMETER_TO_SUBSTITUTE>* POINTERNAME = new CLASSNAME(VARIABLES_FOR_CONSTRUCTOR);

my code specifically looks like:
C_linked_list_node<C_linked_list_data_mystring>* tail = NULL;
C_ordered_linked_list_head_node<C_linked_list_data_mystring>* headnode = new C_ordered_linked_list_head_node(testllmystring, tail);


and I get the following errors:
C:\Game Development\Game testing\stringtest\stringtest.cpp(384) : error C2955: 'C_ordered_linked_list_head_node' : use of class template requires template argument list
c:\game development\misc utilities\linked list.h(76) : see declaration of 'C_ordered_linked_list_head_node'

Any insight would be greatly appreciated! Thanks!
 
If C_ordered_linked_list_head_node is a template, you need to qualify it everywhere. BTW, it's a lot easier to say

typedef C_ordered_linked_list_head_node<whatever> mytype;

and then use mytype like this

mytype* pmt = new mytype;

everywhere.


:) Hope that this helped! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top