devxlogo

Use typedefs when the Template Parameter List Contains Another

Use typedefs when the Template Parameter List Contains Another

Suppose you have the class given below:

 #include #include std::list> list_of_pairs;

In the above definition, the template argument for list is another template class namely, pair. The above definition won’t compile. For ex, VC++ 6.0 gives the following error:

 syntax error : missing ',' before identifier 'list_of_pairs'

The correct way to declare the above is by using a typedef as given below:

 typedef std::pair int_pair;std::list list_of_pairs;
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist