In-Class Initialization Errors

Summary In this post, I will introduce some common compiling errors I used to see related to in-class initialization: Error: in-class initialization of static data member xxx of non-literal type; Error: ISO C++ forbids in-class initialization of non-const static member xxx; Conclusion As usual, I present the correct ways to do in-class initialization at the…

Include Guard V.S. #pragma once

Summary In this post, I will introduce the difference between include guard and #pragma directives in C++. Conclusion As usual, I will present the conclusion first. Include guard is the standard way to prevent multiple inclusion of the same header; #pragma directive is not required by C++ standard but now widely supported by most of…