[ create a new paste ] login | about

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

C++, pasted on Apr 28:
#include <iostream>

#define SOME_DEFINE

class NullClass
{
};

class SomeClass
{
public:
	SomeClass():t(0)
	{
	}
private:
	int t;
};

#ifdef SOME_DEFINE
struct some_struct
{
	typedef NullClass context_type;
	static void some_foo(int t, context_type tp)
	{
		function(t);
	}
	static void function(int t)
	{
	}
};
#else
struct some_struct
{
	typedef SomeClass context_type;
	static void some_foo(int t, context_type tp)
	{
		function(t, tp);
	}
	static void function(int t, context_type tp)
	{
	}
};
#endif

class MainClass
{
public:
	typedef some_struct::context_type context_type;
	MainClass(int some_param_, bool some_flg_):
		context(0), some_param(some_param_), some_flg(some_flg_)
		{
		}
	MainClass(context_type context_, int some_param_, bool some_flg_):
		context(&context_), some_param(some_param_), some_flg(some_flg_)
		{
		}
	void some_function()
	{
		some_struct::some_foo(some_param, *context);
	}
private:
	context_type* context;
	int some_param;
	bool some_flg;
};

int main()
{
	MainClass mc(0, false);
	mc.some_function();
}


Output:
No errors or program output.


Create a new paste based on this one


Comments: