[ create a new paste ] login | about

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

C++, pasted on Jun 14:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
	class Data{
		public:
			std::string str;
			double var;

			template <typename UserType>
			UserType operator()() const { return  (UserType)var;}

			template <typename UserType>
			void operator()(UserType& utype) { var = (UserType)utype; }

	};

int main()
{
Data d;
d.var = 5.5;
cout << d.operator()<int>();

return 0;
}


Output:
1
5


Create a new paste based on this one


Comments: