EBK C++ PROGRAMMING: FROM PROBLEM ANALY
EBK C++ PROGRAMMING: FROM PROBLEM ANALY
8th Edition
ISBN: 9781337514491
Author: Malik
Publisher: CENGAGE LEARNING - CONSIGNMENT
Expert Solution & Answer
Book Icon
Chapter 13, Problem 8SA

Explanation of Solution

The class dateType has a friend function declared in its definition. The friend function is then defined with two parameters of dateType and a bool return type. The logic of the function is explained with the in-lined comments in the program given below.

//class definition

class dateType

{

    //declare the friend function in the class definition

    friend bool before(dateType d1, dateType d2);

    public:

        void setDate(int month, int day, int year);

        int getDay() const;

        int getMonth() const;

        int getYear() const;

        void printDate() const;

        bool isLeapYear(int) const;

        dateType(int month = 1, int day = 1, int year = 1900);

    private:

        int dMonth; //variable to store the month

        int dDay; //variable to store the day

        int dYear; //variable to store the year

};

//define the friend function

bool before(dateType d1, dateType d2){

    //if the year of first object is strictly less

    //than the year of second object return true

    //else if the year of the first object is

    //strictly more than the year of the second

    //object return false else if there is a tie

    //then compare the months

    if (d1...

Blurred answer
Students have asked these similar questions
Write a class Travel having two private data members (distanceCovered , Time) The class has three constructors which are • having no parameter – for setting values to zero or null. • having two parameters for assigning values to both data members. • Overload the above constructor and use this keyword to set the values of data members. • Provide getters/setters for data members. • A function which calculates and display speed of traveling. • Write a function show() displays values.   Write test Application that demonstrates the Run class by calling all the three constructors and method, creating a Create Travel objects, and then display the traveling with speed. Calculate highest speed. Programming language : java
Write a class Box having three private data members (width, depth, height) The class has three constructors which are having no parameter – for setting values to zero or null. having three parameters for assigning values to height, width, depth respectively. Overload the above constructor and use this keyword to set the values of width, height & depth. Provide getters/setters for data members. Write a function calculateVolume() which calculates the volume of the box.   Write test Application that demonstrates the Box class by calling all the three constructors and method, creating a Create Box object, and then displaying the Box’swidth , height, length and volume .
a. Write the specification (i.e., what would be in a header file) for a class called studentType. Code the data member section (as private) and the function prototypes (as public). You do not need to write any include, using or other directives. Include the following: Data: Student First Name Student Last Name Student gpa Student ID Functions: Default constructor Set the first name Get the first name Set the last name Get the last name Set the gpa Get the gpa Set the ID Get the ID b. Create an object of studentType using the default constructor. 3.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning