Newsgroups: comp.lang.c++ Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Syntax error when defining conversion operator Message-ID: <1988Nov25.175714.9248@utzoo.uucp> Organization: U of Toronto Zoology References: <337@maxim.ERBE.SE> Date: Fri, 25 Nov 88 17:57:14 GMT In article <337@maxim.ERBE.SE> prc@ERBE.SE (Robert Claeson) writes: >In a class, I want to define a conversion operator from the class >to unsigned long. So, I write: >... > operator unsigned long() { return bar; } > ... >When I compile this (AT&T C++ Translator 1.1), get a "syntax error" >from cfront. I've found NOTHING in the manual that prevents me from >defining conversion operators for multi-word data types. Is there any >way to circumvent this? You're going to have to use a typedef. If you look at the C++ Reference Manual (in the back of The Book), you'll find that the name of a conversion operator must be a "simple type name", and if you look up the definition of that, you'll find that it essentially means "one word". So you'll need to use a typedef to give "unsigned long" a one-word name. -- Sendmail is a bug, | Henry Spencer at U of Toronto Zoology not a feature. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu