Question 41

What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
char *s = "ABCDEF";
cout << s+2;
return 0;
}
  • Question 42

    What happens when you attempt to compile and run the following code?
  • Question 43

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    #include <string>
    using namespace std;
    void fun(int i);
    int main()
    {
    int i=0;
    i++;
    for (i=0; i<=5; i++)
    {
    fun(i);
    }
    return 0;
    }
    void fun(int i)
    {
    if (i==3)
    return;
    cout << i;
    }
  • Question 44

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    using namespace std;
    class First
    {
    public:
    virtual void Print(){ cout<<"from First";}
    };
    class Second:public First
    {
    public:
    void Print(){ cout<< "from Second";}
    };
    void fun(First *obj);
    int main()
    {
    First FirstObject;
    fun(&FirstObject);
    Second SecondObject;
    fun(&SecondObject);
    }
    void fun(First *obj)
    {
    obj?>Print();
    }
  • Question 45

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    #include <string>
    using namespace std;
    class A {
    int x;
    protected:
    int y;
    public:
    int z;
    };
    class B : public A {
    string name;
    public:
    void set() {
    y = 2;
    z = 3;
    }
    void Print() { cout << y << z; }
    };
    int main () {
    B b;
    b.set();
    b.Print();
    return 0;
    }