Skip to content

Instantly share code, notes, and snippets.

View fortheday's full-sized avatar
🤩

magicpotato fortheday

🤩
View GitHub Profile
const int i = 3;
const_cast<int&>(i) = 4;
class CBase
{
public:
virtual void Print() = 0; // pure virtual, abstract
};
class CDerived0 : public CBase
{
public:
CDerived0() { puts("new0"); }
class CCar
{
class CWheel *pWheels[4]; // inline forward declaration
};
int *i1 = new int; // 초기화안됨
int *i2 = new int();// 됨
int i3 = int(); // 됨
int i4(0); // 됨
int i5{0}; // 됨
int i6(); // 컴파일에러
cout << *i1 << ' ' << *i2 << ' '<< i3 << ' ' << i4 << ' ' << i5 << endl;
char *pArr1 = new char[10]; // 초기화안함
char *pArr2 = new char[10](); // '\0' 으로 초기화
enum class EDay { Mon, Tue, Web, Thu, Fri, Sat, Sun };
EDay day = EDay::Mon;
unsigned char b = 0b1010; // 10
int i = 1'000'000;
thread_local int tls_ThreadID;
__declspec(thread) int tls_ThreadID_Old;
int x = 2;
constexpr int GetDays() { return 2018 * 365; }
constexpr int todayDays1 = GetDays() * 1; // OK
constexpr int todayDays2 = GetDays() * x; // CompileTime Error
const int todayDays = GetDays() * x; // OK, Runtime initialize
using byte = unsigned char; // typedef unsigned char byte;
byte bByte = 0xFF;
namespace Level0
{
namespace Level1
{
int e_Year = 2018;
}
inline namespace Group1
{
int e_Month = 1;