What does a semicolon after a class name do?

This question already has an answer here:

  • What is the difference between a definition and a declaration? 25 answers

  • These are forward declarations. They let the following code know that there is are classes with the names RenderWindow , StateStack , and Player . This satisfies the compiler when it sees these names used. Later the linker will find the definition of the classes.


    It is a forward declaration, essentially it signals to the compiler that the full definition will follow elsewhere.

    The primary use case for this is cases where you do not need the full definition, for example if you have a pointer of type T you don't need the full definition of T until instantiation and thus its not required to have for a declaration of T* .

    链接地址: http://www.djcxy.com/p/40618.html

    上一篇: 花括号对空构造函数是否重要?

    下一篇: 类名后面的分号是干什么的?