Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors in simple template code

template <class T>
struct ABC
{
      typedef typename T* pT;     
};

int main(){}

The above piece of code gives errors

expected nested-name-specifier before 'T'
expected ';' before '*' token

What is wrong with the code sample?

like image 783
NewToStackOverflow Avatar asked Oct 16 '10 07:10

NewToStackOverflow


People also ask

What is a 500 page?

500 pages is 250000 words single-spaced or 125000 words double-spaced. Typical documents that are 500 pages or more include full-length novels. A typical single-spaced page is 500 words long. It will take approximately 833 minutes to read 500 pages.

What is Template in HTML and CSS?

The <template> tag is used as a container to hold some HTML content hidden from the user when the page loads. The content inside <template> can be rendered later with a JavaScript. You can use the <template> tag if you have some HTML code you want to use over and over again, but not until you ask for it.


1 Answers

The keyword typename is forbidden on unqualified names (those not preceded by ::), even if they are dependent.

C++03 [Section 14.6/5] says

The keyword typename shall be applied only to qualified names, but those names need not be dependent.

pt is dependent on T but that doesn't matter (in this context).

Remove typename to make your code compile.

like image 125
Prasoon Saurav Avatar answered Sep 17 '22 22:09

Prasoon Saurav