Path: utzoo!mnetor!uunet!husc6!rutgers!mtune!lzaz!lznv!mark From: mark@lznv.ATT.COM (MARK SMITH) Newsgroups: comp.lang.c++ Subject: Typechecking types different from immediate type. Message-ID: <1232@lznv.ATT.COM> Date: 28 Dec 87 19:19:41 GMT Organization: AT&T ISL Middletown NJ USA Lines: 44 Here's an interesting consequence of implicit initialization in C++: We intend the following: class A { int i; public: A( int newi ) { i = newi; } }; main() { A abc( 0 ); extern F( &A ); // ... { F( abc ); } } This works fine...but if our program has a bug (in my case, left over from an earlier version) that accidentally renames abc in the inner scope: main() { A abc( 0 ); extern F( &A ); // ... { int abc = 1; F( abc ); } } C++ is happy to convert the int abc into an A for us. Compile typechecking doesn't prevent this type of pilot error. Generally, for each type T there is an associated typechecking type T', decidedly *not* T, defined as a union of types T' = { T, t1, t2, ... } where constructors T( t1 ), T( t2 ), ... have been defined. Mark Smith lznv!mark