1*c87b03e5Sespie // GROUPS passed conversions 2*c87b03e5Sespie // cvt file 3*c87b03e5Sespie // Message-Id: <9301071708.AA03432@muresh.et.tudelft.nl> 4*c87b03e5Sespie // From: stravers@muresh.et.tudelft.nl (Paul Stravers) 5*c87b03e5Sespie // Subject: conversion method never called 6*c87b03e5Sespie // Date: Thu, 7 Jan 93 18:08:33 +0100 7*c87b03e5Sespie 8*c87b03e5Sespie #include <stdio.h> 9*c87b03e5Sespie 10*c87b03e5Sespie class test 11*c87b03e5Sespie { 12*c87b03e5Sespie double d; 13*c87b03e5Sespie int i; 14*c87b03e5Sespie public: test(double dd,int ii)15*c87b03e5Sespie test(double dd,int ii) {d=dd; i=ii;} // constructor 16*c87b03e5Sespie operator int&() {return i;} // define a conversion from test to int& geti()17*c87b03e5Sespie int& geti() {return i;} // same thing, but different 18*c87b03e5Sespie }; 19*c87b03e5Sespie main()20*c87b03e5Sespieint main() 21*c87b03e5Sespie { 22*c87b03e5Sespie test t(3.14, 5); // Create an object t of class "test" 23*c87b03e5Sespie int x = (int&)t; // This should call operator int&() but it does not ... 24*c87b03e5Sespie int y = t.geti(); // x and y should both be 5 ... 25*c87b03e5Sespie if (x == 5 && y == 5) 26*c87b03e5Sespie printf ("PASS\n"); 27*c87b03e5Sespie else 28*c87b03e5Sespie { printf ("FAIL\n"); return 1; } 29*c87b03e5Sespie } 30