출처 C++11에서 새로 추가됨 int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t, uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t, int_least8_t, int_least16_t, int_least32_t, int_least64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t, intmax_t, uintmax_t, intptr_t, uintptr_t 아래 헤더 파일을 추가해야 한다 #include <cstdint> std::int8_t...
더 읽기
출처 Visual C++ 전용 키워드 이다. __if_exists ( identifier ) { statements }; identifier에 전달한 식별자가 존재한다면 statements가 실행된다. 부정형으로 __if_not_exists가 있다. 컴파일 타임 때 실행. template<typename T> class X : public T { public: void Dump() { __if_exists(T::Dump) {...
더 읽기
아래 코드처럼 virtual 이 붙은 가상 기반 클래스는 “모호성” 을 피하기 위함이다. class B : virtual public A{} class C : virtual public A{} class D : public B, public C{} 가상 기반 클래스가 아니라면 D 클래스가 생성시에 A 를...
더 읽기
몇 년전에 웹에 공개된 글을 보고 정리했던 글이다.
더 읽기
class Base { public : virtual void f() { } } ; class Derived : public Base { private : void f() { } } ; int main() { Derived d ; d.f(); // 1. ? Base & ref =...
더 읽기
C++ 표준은 아니고 VC++ 7.0에서 생긴 키워드로 자식 클래스에서 부모 클래스의 멤버를 호출할 때 사용하면 편리하다. 이 키워드를 사용하면 부모 클래스의 이름이 바뀌어도 변경 없이 부모 클래스의 멤버를 호출할 수 있다. struct B1 { void mf(int) {} }; struct B2...
더 읽기
일반적인 함수의 기본 인자 값 void TEST_1(int nValue = 5 ) { std::cout << __FUNCTION__ << ". " << nValue << std::endl; } 위의 디폴트 값은 고정인데 아래처럼 동적으로 바꿀 수 있다. #include <iostream> #include <time.h> int GetNumber() { return...
더 읽기
보통 다른 클래스를 friend로 선언할 때 그 클래스 전체를 선언하는 경우가 많은데 클래스 전체가 아닌 일부 멤버 함수만을 friend로 선언할 수 있다. struct TEST2; struct TEST1 { void T1(); void T2(); }; struct TEST2 { friend void TEST1::T1(); private: int...
더 읽기
몇 년전에 웹에 공개된 글을 보고 번역했던 글이다.
더 읽기