C++ 11 "class" keyword -



C++ 11 "class" keyword -

i've started using c++ 11 little bit more , have few questions on special uses of class keyword. know it's used declare class, there's 2 instances have seen don't understand:

method<class t>();

and

class class_name *var;

why precede typename keyword class in first example, , keyword pointer in sec example?

that known elaborated type specifier , necessary when class name "shadowed" or "hidden" , need explicit.

class t { }; // love of god don't t t; t t2;

if compiler smart, give these warnings:

main.cpp:15:5: error: must utilize 'class' tag refer type 't' in scope t t2; ^ class main.cpp:14:7: note: class 't' hidden non-type declaration of 't' here t t; ^

if class not defined, deed forwards declaration.

for example:

template <typename t> void method() { using type = typename t::value_type; } method<class t>(); // t forwards declaration, have not defined yet, // error.

otherwise it's not necessary.

class t { public: using value_type = int; }; // method implementation... method<t>(); method<class t>(); // class redundant here

c++

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -