|
|
Darren New <dne### [at] sanrrcom> wrote:
> they warn you if you pass
> the wrong types to printf with a literal formatting argument (which is why
> the iostream argument that it's better because it's strongly typed never
> made much sense to me)
It depends on the compiler. Some compilers, especially the slightly older
ones, don't make such checks.
Of course the major problem with the printf-style of I/O is that it breaks
abstraction, even in C. You just have to do something this to get a problem:
typedef int MySpecialInt;
...
void foo(MySpecialInt i)
{
printf("The parameter was: %???\n", i);
}
What to put as a format? Even if you put "%i" and have it work ok, it
breaks the abstraction of MySpecialInt because now you can't change it
without breaking the printf. Obviously the C++ streams have no such
problem.
--
- Warp
Post a reply to this message
|
|