Created
June 18, 2015 19:30
-
-
Save catchouli/fe044cb5c51d3122d42a to your computer and use it in GitHub Desktop.
pimpl - dont forget your copy constructors and shit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
class SomeClass | |
{ | |
public: | |
SomeClass(); | |
~SomeClass(); | |
SomeClass(const SomeClass&); | |
SomeClass& SomeClass(const SomeClass&); | |
private: | |
struct Impl; | |
Impl* m_impl; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "header.hpp" | |
#include <Windows.h> | |
struct SomeClass::Impl | |
{ | |
Impl() : m_someHandle(INVALID_HANDLE) {} | |
HANDLE m_someHandle; | |
}; | |
// Use a smart pointer if possible | |
// And dont forget your copy or move construction/assignment | |
SomeClass() | |
: m_impl(new Impl) {} | |
~SomeClass() | |
{ | |
delete m_impl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment