Newer
Older
Import / research / other / sandbox / CPP-test / CPP-test.cpp
@John Ryland John Ryland on 22 Dec 2020 820 bytes import NUC files
/*
	Copyright (c) 2013, John Ryland
 */
#include <stdlib.h>
#include <stdio.h>


class TestClass
{
public:
	TestClass() { }
	TestClass(int i) : m_i(i) { }
	void SomeMethod()
	{
		printf("i=%i\n", m_i);
	}
	int m_i;
	static TestClass s_null;

void operator SomeMethod()()
{
	printf("Okay\n");
}


/*
TestClass& operator->()
{
	if ( this == 0 )
	{
		printf("Naughty\n");
		return s_null;
	}
	printf("Okay\n");
	return *this;
}

TestClass* operator&()
{
	if ( this == 0 )
		printf("Naughty\n");
	printf("Okay\n");
}
*/
};

typedef TestClass &TPtr;



int main()
{
	TestClass obj;
	printf("1\n");
	TestClass *objPtr1 = &obj;
	printf("2\n");
	TestClass *objPtr2 = (TestClass*)0;
	printf("hello\n");
	//obj = 0;
	*objPtr1;
	objPtr1->SomeMethod();
	printf("good\n");
	//objPtr2->SomeMethod();
	printf("done\n");
	return 0;
}