C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
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
Given the following request to an AI chatbot, which response is more accurate? (You should use Google to verify that the factual claims in each response are accurate.)   Prompt Is this true? The first recorded use of the phrase "when pigs fly" in print is in a 1616 play by Ben Jonson called "The Devil is an Ass," in which a character says, "When pigs fly, good-night!!" Response   Response A Response B Yes, that's true! The phrase "when pigs fly" indeed appears in Ben Jonson's 1616 play The Devil is an Ass and was said during the second act in a conversation between Fitzdottrel and Pug. The phrase was first used to express skepticism or disbelief, suggesting that something is as unlikely to happen as the fanciful idea of pigs flying. This usage is often cited as one of the earliest instances of the phrase in print.   The claim that the phrase "when pigs fly" was first recorded in Ben Jonson's 1616 play "The Devil is an Ass" is not accurate. There is no evidence from the…
This is for my Computer Organization & Assembly Language Class
Please answer the homework scenario below and make a JAVA OOP code. You have been hired by GMU to create and manage their course registration portal. Your first task is to develop a program that will create and track different courses in the portal.  Each course has the following properties:  • a course number ex. IT 106, IT 206,  • A course description, ex. Intro to Programming • Total credit hour ex. 3.0, and  • current enrollment ex. 30 Each course must have at least a course number and credit hours. The maximum enrollment for each course is 40 students. The current enrollment should be no greater than the maximum enrollment. A course can have a maximum of 4 credit hour. The DDC should calculate the number of seats remaining for the course. Design an object-oriented solution to create a data definition class for the course object. The course class must define all the constructors, mutators with proper validation, accessors, and special purpose methods. The DDC should calculate the…
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
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,