Pointers


  1. What is the meaning of the following declaration?
    int(*p[10])();











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this expression, p is array not pointer.


  1. Which is the best design choice for using pointer to member function?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Interface



  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class N
    {
    public:
    N(int k = 0){ _k = k;}
    void fun()
    {
    cout << "Program Executed..."< }
    private:
    int _k;
    };
    int main()
    {
    N *ptr = 0;
    ptr -> fun();
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    In this program, We passes the value to the class and printing it.


  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Car
    {
    public:
    int Lamborghini;
    int Audi;
    };
    int count_CarType(Car * begin, Car * end, int Car :: *CarType)
    {
    int count = 0;
    for (Car * iterator = begin; iterator != end; ++ iterator)
    count += iterator ->* CarType;
    return count;
    }
    int main()
    {
    Car CarArray[5] = {{ 4, 2 },{ 6, 1 }};
    cout << "I have " << count_CarType(CarArray, CarArray + 2, & Car :: Lamborghini) << " Lamborghini.\n";
    cout << "And I have " << count_CarType(CarArray, CarArray + 2, & Car :: Audi) << " Audi.";
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In this program, We are passing the value to the class and adding the values and printing it in the main.



  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Lamborghini
    {
    public:
    int speed;
    };
    int main()
    {
    int Lamborghini :: *ptrSpeed = &Lamborghini :: speed;
    Lamborghini obj;
    obj.speed = 4;
    cout << obj.speed << endl;
    obj.*ptrSpeed = 5;
    cout << obj.speed << endl;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this program, We are printing the value by direct access and another one by using pointer to member.