Write a program that prints pointer values, using casts to all the integer data types. Which ones print strange values? Which ones cause errors?

What will be an ideal response?

```
#include
using namespace std;

int main()
{
// string to cast into integer formats
char *string = "test";

// display data stored in string and
// address of string using static_cast
cout << "Value of string is : " << string << '\n'
<< "Value of static_cast( string ) is : "
<< static_cast( string ) << '\n'

// The following generate errors.
// reinterpret_cast will allow this type of casting.
// See Ch. 24 for a discussion of reinterpret_cast.

/* << "Value of static_cast(string) is : "
<< static_cast( string ) << '\n'
<< "Value of static_cast(string) is : "
<< static_cast( string ) << '\n'
<< "Value of static_cast(string) is : "
<< static_cast( string ) << '\n'
<< "Value of static_cast(string) is : "
<< static_cast( string ) << '\n'
<< "Value of static_cast(string) is : "
<< static_cast( string )
*/
<< endl;
} // end main
```
Value of string is : test
Value of static_cast( string ) is : 0046C080

Computer Science & Information Technology

You might also like to view...

After you edit a source Flash file, Dreamweaver automatically republishes the movie as a(n) ____ file.

A. FLA B. SWF C. FLS D. SWA

Computer Science & Information Technology

Java bears a superficial resemblance to C++.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology