r access specifiers ](/w/cpp/language/access "cpp/language/access")  
[ Constructors and member initializer lists ](/w/cpp/language/constructor
"cpp/language/constructor")  
[ Default member initializer
](/w/cpp/language/data_members#Member_initialization "cpp/language/data
members") (C++11)  
[ ` friend ` specifier ](/w/cpp/language/friend "cpp/language/friend")  
[ ` explicit ` specifier ](/w/cpp/language/explicit "cpp/language/explicit")  
[ Converting constructor ](/w/cpp/language/converting_constructor
"cpp/language/converting constructor")  
Special member functions  
[ Default constructor ](/w/cpp/language/default_constructor
"cpp/language/default constructor")  
[ Copy constructor ](/w/cpp/language/copy_constructor "cpp/language/copy
constructor")  
[ Move constructor ](/w/cpp/language/move_constructor "cpp/language/move
constructor") (C++11)  
[ Copy assignment operator ](/w/cpp/language/copy_assignment
"cpp/language/copy assignment")  
[ Move assignment operator ](/w/cpp/language/move_assignment
"cpp/language/move assignment") (C++11)  
[ Destructor ](/w/cpp/language/destructor "cpp/language/destructor")  
Inheritance  
[ Base and derived classes ](/w/cpp/language/derived_class
"cpp/language/derived class")  
[ Empty base optimization (EBO) ](/w/cpp/language/ebo "cpp/language/ebo")  
[ Virtual member functions ](/w/cpp/language/virtual "cpp/language/virtual")  
[ Pure virtual functions and abstract classes ](/w/cpp/language/abstract_class
"cpp/language/abstract class")  
[ ` override ` specifier ](/w/cpp/language/override "cpp/language/override")
(C++11)  
[ ` final ` specifier ](/w/cpp/language/final "cpp/language/final") (C++11)  
  
[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/language/classes/navbar_content&action=edit)

The injected-class-name is the unqualified name of a class within the scope of
said class.

In a [ class template ](/w/cpp/language/class_template "cpp/language/class
template") , the injected-class-name can be used either as a template name
that refers to the current template, or as a class name that refers to the
current instantiation.

##  Contents

  * 1  Explanation 
  * 2  In class template 
  * 3  injected-class-name and constructors 
  * 4  Defect reports 

  
---  
  
###  [ [ edit ](/mwiki/index.php?title=cpp/language/injected-class-
name&action=edit&section=1 "Edit section: Explanation") ]  Explanation

In a class scope, the name of the current class is treated as if it were a
public member name; this is called _injected-class-name_ . The point of
declaration of the name is immediately following the opening brace of the
class definition.

    
    
    int X;
     
    struct X
    {
        void f()
        {
            X* p;   // OK. X refers to the injected-class-name
            ::X* q; // Error: name lookup finds a variable name, which hides the struct name
        }
    };

Like other members, injected-class-names are inherited. In the presence of
private or protected inheritance, the injected-class-name of an indirect base
class might end up being inaccessible in a derived class.

    
    
    struct A {};
    struct B : private A {};
    struct C : public B
    {
        A* p;   // Error: injected-class-name A is inaccessible
        ::A* q; // OK, does not use the injected-class-name
    };

###  [ [ edit ](/mwiki/index.php?title=cpp/language/injected-class-
name&action=edit&section=2 "Edit section: In class template") ]  In class
template

Like other classes, class templates have an injected-class-name. The injected-
class-name can be used as a template-name or a type-name.

In the following cases, the injected-class-name is treated as a template-name
of the class template itself:

  * it is followed by ` ** < ** `
  * it is used as a [ template template argument ](/w/cpp/language/template_parameters#Template_template_arguments "cpp/language/template parameters")
  * it is the final identifier in the [ elaborated class specifier ](/w/cpp/languag