Pointers


  1. The pointer can point to any variable that is not declared with which of these?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    both volatile & const


  1. What is the output of this program?
    #include 
    using namespace std;
    int fun(void *P);
    int main()
    {
    char *S = "Interview Mania";
    fun(S);
    return 0;
    }
    int fun(void *P)
    {
    cout << P;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Even though it is a void pointer, we gets the address.



  1. A void pointer cannot point to which of these?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    A void pointer cannot point to methods in c++ and class member in c++.


  1. What is the output of this program?
    #include 
    using namespace std;
    int main()
    {
    int *ptr;
    void *vptr;
    if (vptr == ptr)
    {
    cout << "Interview Mania";
    }
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The void pointer is easily converted to any other type of pointer, so these are equal.



  1. When does the void pointer can be dereferenced?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    By casting the pointer to another data type, it can be dereferenced from the void pointer.