June 6, 1997

Truncating and converting floats

Question: I am trying to truncate and then convert a float to a string. Something like atoi().Is this possible? Any suggestions? Answer: float f = 1.234;int i = f;strstream s;s

Template functions in classes

Question: Can I overload the >> operator in a class for all integral types using a template? If so, how? Answer: The short answer is no.The long answer?Templates are mechanisms

Exception specifications

Question: I recently learned that the C++ draft standard requires that an implementation not perform any static checking on a function’s exception specification (aside from inherited virtual functions and function

I/O stream and opening to a file

Question: I have a completed program coded as a bubble sort. I must now read and write to a file. I am using fstream.h and coding an input for the

How does one overload operator->*()?

Question: How does one overload operator->*()? Answer: Here is an example:struct bar { void doSomething();}struct foo { bar *operator ->* () { return bar_; }}void Foo (){ void (bar::*barFn)() =

Type casting

Question: I’ve read the following example about type casting: int i; float f; f=float(i);Can you explain what happens to variables f and i on line 3, and could you give