Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Help C++ Questions (http://www.go4expert.com/forums/help-cpp-questions-t25412/)

zackary13 3Apr2011 22:13

Help C++ Questions
 
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?

xpi0t0s 4Apr2011 21:01

Re: Help C++ Questions
 
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).

zackary13 5Apr2011 06:54

Re: Help C++ Questions
 
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.

xpi0t0s 5Apr2011 15:20

Re: Help C++ Questions
 
Older brother, is he?


All times are GMT +5.5. The time now is 12:53.