1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help C++ Questions

Discussion in 'C++' started by zackary13, Apr 3, 2011.

  1. zackary13

    zackary13 New Member

    Joined:
    Mar 28, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    I have some questions that I need by tonight because my brother bet that I couldn't find these answers by tonight by asking people online and he said that people online wouldn't help so I would like to prove him wrong.

    Please number the questions if you answer, thanks


    • In C++, there is a function called "assert"

      What is it? and should you use it often? why? example?


    2. If we have a virtual function in our base class, can we change the modifier of the function?

    See the example




    class Base {

    public:

    virtual double calculateHealth() const;

    };



    Our inherited class




    class Derived : public Base {

    public:

    int calculateHealth() const;

    };



    Is this allow? why or why not?



    • What is slicing? Should you avoid it at all cost? If so, why? and what alternative should you consider if you decide to avoid slicing at all costs?


    4. You might have seen public and private inheritance.

    what's the different between the two?


    class RedBoss : public Enemy



    vs

    class RedBoss : private Enemy


    5. What's the different between the following?

    #define MAX_MENU 3

    vs

    const int MAX_MENU = 3;

    What's the up and down for using each? when do you use it?
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Seems a funny thing for your brother to demand. Are you sure it's really your brother and this isn't just a fancy way of getting people to do your homework for you? Try reading your course notes - this really is the best help I can give you (cos just answering the questions for you teaches you nothing about programming).
     
  3. zackary13

    zackary13 New Member

    Joined:
    Mar 28, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Well thanks for at least responding but I am 15 years old and I am not part of any course involving this but I owed my brother 50 dollars because I posted on 3 different forums but only got two responses.
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Older brother, is he?
     

Share This Page