aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C
blob: 57f3b426108aa4ce85f9589ccb5a078cafa1adde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Build don't link: 
// GROUPS passed conversions
#include <iostream.h>

class Thing
{
public:
      typedef enum { GOOD_THING, BAD_THING, } ThingType ; // ERROR - comma
	Thing (ThingType type) : thingType (type) { }
	~Thing () { }
private:
	ThingType thingType ;
} ;

class Group
{
public:
      typedef enum { THIS_GROUP, THAT_GROUP, } GroupType ; // ERROR - comma
	Group (GroupType type) : groupType (type), groupCount (0) { }
	~Group () { }
	void append (Thing* const &entry) { groupCount ++ ; }
	operator GroupType () const { return groupType ; }
	operator int () const { return groupCount ; } // remove this and problem gone

private:
	int groupCount ;
	GroupType groupType ;
} ;

inline Group& operator += (Group& g, Thing* const t)
{
	g.append (t) ;
	return g ; // complaint is here
}

int
main (int argc, char** argv)
{
	Group g (Group::THIS_GROUP) ;

	g += new Thing (Thing::GOOD_THING) ;
	cout << "Group type is " << (Group::GroupType) g << endl ;
	return 0 ;
}