[ create a new paste ] login | about

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

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

struct custom;

struct converted {
  operator custom();
};

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

  struct converted : ::converted {};

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

	private:
		int i;
};

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

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

	return 0;
}


Output:
1
2
3
cc1plus: warnings being treated as errors
In function 'int main()':
Line 29: warning: cannot pass objects of non-POD type 'struct custom' through '...'; call will abort at runtime


Create a new paste based on this one


Comments: