>>>> "Ben" == Ben Wing <ben(a)666.com>
writes:
Ben> I don't know C++ that well, and the book I have on it (Stroustrop, 2nd
Ben> ed, I think) is 10 years old at least.
You can fix that. Get the 3rd edition.
Ben> XEmacs has typedefs such as Bytecount and Charcount. Currently they are
Ben> just ints but I'd like to introduce some additional type-checking using
Ben> C++. In particular, I'd like to define them as classes, with the normal
This is a good idea - one of many reasons for C++ compilation.
Ben> operators overloaded in normal ways, and to allow free mixing (more or
Ben> less) between these types and ints (at the very least, it's reasonable
Ben> to pass constant ints to a function expecting a Bytecount or Charcount).
Ben> What I don't want is to be able to pass one of them to a function
Ben> expecting the other -- but it *should* be possible with an explicit
Ben> cast, e.g. (Bytecount) x. Problem is, the "cast operator" that can be
Ben> defined on a class seems to define implicit casts, not explicit. Is
Ben> there any way to do what I want?
You want the "explicit" keyword.