Help C++ Questions

zackary13's Avatar, Join Date: Mar 2011
Light Poster
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?
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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).
0
zackary13's Avatar, Join Date: Mar 2011
Light Poster
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.
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Older brother, is he?