Skip to content

Instantly share code, notes, and snippets.

@kioba
Created November 10, 2015 15:20
Show Gist options
  • Save kioba/837d1697304802b5d6aa to your computer and use it in GitHub Desktop.
Save kioba/837d1697304802b5d6aa to your computer and use it in GitHub Desktop.
C11 explicit delete class function
#include <iostream>
class Destructor
{
public:
Destructor();
virtual ~Destructor() = delete;
void print();
};
Destructor::Destructor()
{
}
void Destructor::print()
{
std::cout << "asd" << std::endl;
}
int main()
{
// stack
// Destructor destStack; // compiler error: could not be constructed!
// destStack.print();
// heap: Does it works?
Destructor* destHeap = new Destructor;
destHeap->print();
delete destHeap;
std::cin.get();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment