C++ Pointer to an Object Question

Question

Write a program that defines an object of type double.

Define a pointer that points to that object.

Print the value of the pointed-to object by dereferencing a pointer.

You can use the following code structure.

#include <iostream> 

int main() 
{ 
    //your code here
} 


#include <iostream> 

int main() 
{ 
    double d = 3.14; 
    double* p = &d; 
    std::cout << "The value of the pointed-to object is: " << *p; 
} 



PreviousNext

Related