Jump to content
  • Advertisement
  • entries
    146
  • comments
    436
  • views
    198491

C++ Quiz #2

Sign in to follow this  
Washu

578 views

This is a test of your knowledge of C++, not of your compiler's knowledge of C++. Using a compiler during this test will likely give you the wrong answers, or at least incomplete ones.




  1. Using the code below as a reference, explain what behavior should be expected of each of the commented lines, please keep your answer very short.



    struct Base {
    virtual void Arr();
    };
    struct SubBase1 : virtual Base { };
    struct SubBase2 : virtual Base {
    SubBase2(Base*, SubBase1*);
    virtual void Arr();
    };


    struct Derived : SubBase1, SubBase2 {
    Derived() : SubBase2((SubBase1*)this, this) { }
    };
    SubBase2::SubBase2(Base* a, SubBase1* b) {
    typeid(*a); //1
    dynamic_cast<SubBase2*>(a); //2
    typeid(*b); //3
    dynamic_cast<SubBase1*>(b); //4
    a->Arr(); //5
    b->Arr(); //6
    }

  2. Using the code below as a reference, explain what behavior should be expected of each of the commented lines?



    template<class T> class X {
    X<T>* p; //1
    X<T> a; //2
    };



Source
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!