[ create a new paste ] login | about

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

C++, pasted on Feb 20:
#include <cstdio>

struct custom {
	custom(int i): i(i) { }

	friend inline custom operator + (const custom &lhs, const custom &rhs) {
		return lhs.i + rhs.i;
	}

	private:
		int i;
};

struct converted {
	inline operator custom () {
		return custom(2);
	}
};

int main()
{
	converted c;
	printf("%d\n", c + c);

	return 0;
}


Output:
1
2
3
In function 'int main()':
Line 23: error: no match for 'operator+' in 'c + c'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: