(C XXXXXXXXXXThe preprocessor directive #ifndef can be used in a class header file to a) Prevent the class declaration from being included multiple times b) Declare a class namespace c) Implement the...



(C++) 21. The preprocessor directive #ifndef can be used in a class header file to


a) Prevent the class declaration from being included multiple times


b) Declare a class namespace


c) Implement the class member functions


d) None of the above


For questions 22 and 23, refer to the following code:


class SwimmingPool
{
  private:
    int area;
    int gallons;
  public:
    SwimmingPool();
    void setArea(int);
    void setGallons(int);
    int getGallons() const
      { return gallons; }
};





22. Which of the following lines of code would you have in an implementation of the setGallons function?


a) SwimmingPool()


b) void SwimmingPool::setGallons(int g)


c) SwimmingPool::SwimmingPool()


d) void SwimmingPool()::setGallons(int g)




23. True/False:
function getGallons() is an inline member function





24. Design a class called Date.


The class should store a date in three private integers: month, day, year.


There should be a member function to print out the date in the month/day/year format, e.g. 12/25/2015, 4/1/1970


There should be a constructor which takes three parameters to initialize the date.  It should not accept values for day greater than 31 or less than 1, or values for month greater than 12 or less than 1.  If the constructor is called with these values an error message should be printed out and the field set to 0.  Any value for year is acceptable.


There do not need to be any other member functions.


Provide the class declaration and also the implementation of the member function and constructor.




Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here