[ create a new paste ] login | about

Link: http://codepad.org/Dbpg8Xp0    [ raw code | output | fork ]

C++, pasted on Sep 24:
//A.h
#pragma once
#include <stdio.h>
#include <stdlib.h>
class A
{
public:
	static A* Instance();
private:
	A(void);
	static void Destruct();
	static A* _instance;
};

//A.cpp
#include "A.h"

A* A::_instance = NULL;

A* A::Instance()
{
	if (!_instance)
	{
		_instance = new A;
		atexit(&Destruct);
	}
	return _instance;
}

A::A(void)
{
}

void A::Destruct(void)
{
	if (_instance)
	{
		delete _instance;
	}
}


Output:
1
2
Line 8: error: #pragma once in main file
Line 14: error: A.h: No such file or directory


Create a new paste based on this one


Comments: