Q: How can I output hex values in upper case using the iostream libraries?
A: You need to set the state of the stream using setf(). For example,
#include
int main(void)
{
cout <<>
cout << "\nNot upper-case : " <<>
cout.setf(ios::upper-case);
cout << "\nUppercase : " <<>
return 0;
}
Q. What is the "this" pointer?
A. "this" is a local variable in the body of a non-static member function.
It is a pointer to the object for which the function was invoked. It
cannot be used outside of a class member function body.
Q. Why does a binary member function only accept a single argument?
A. The first argument is defined implicitly.
Q. Looking through the class libraries there are definitions in classes
which look like:
class test {
int funct( void ) const;
};
What is the const keyword doing here?
A. There is a pointer to the object for which a function is called
known as the 'this' pointer. By default the type of 'this'
is X *const ( a constant pointer). The const keyword changes the
type to const X *const ( a constant pointer to constant data ).
Q: I want to use _new_handler and set_new_handler.
A: Turbo C++ supports _new_handler and set_new_handler. The type of
_new_handler is as follows.
typedef void (*vfp)(void);
vfp _new_handler;
vfp set_new_handler( vfp );
Q: I would like to use C++ fstreams on a file opened in binary mode,
how is this done?
A: Use ios::binary as the open mode for the file:
#include
ifstream binfile;
binfile.open("myfile.bin", ios::binary);
No comments:
Post a Comment