Knowledge Seeker wrote: > Brett ! > > Us guys, always suggest "Do the homework yourself". So I was trying to > do mine :) > > I was given a tricky question, and I was attempting for it, as > consequence I landed on the following. > > Anyways, I am still thinking on it. > > I will post the question if I am unable to solve it ;)
Brett was just asking the reason why you needed to create a derived class for a basic data type. I guess it does seem kind of strange that you can't do that since you can "create new data types"* using classes and inheritance but not with the basic data types**. * A lot of books say that "classes/templates allow you to create new data types". I say it just creates a new class or template. ** What you want to do seems an awful lot like Java's so-called basic data types. I can't think of any scenarios where doing this would be useful*** (except maybe some inlined functions for bitwise manipulation). Operator overloading of basic types would be dangerous at best. You would be pretty restricted as to what you _could_ do even if it were allowed. And those restrictions would create a lot of people exploring things that generate undefined behavior...like the i++ + ++i discussions this list receives constantly. *** Safe C++ Design Principles doesn't use 'char'. Instead, I redefine the basic data types (using typedef's - e.g. 'char' is SByte...'signed byte') for a reason: Easy portability without having to modify a ton of code. Book is in the Files section of the c-prog website and is free for c-prog members. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* VerifyMyPC 2.5 Change tracking and management tool. Reduce tech. support times from 2 hours to 5 minutes. http://www.CubicleSoft.com/VerifyMyPC/
