Question: C + + / / Step 1 : Define a Public Class: Declare a Date class with public members: class Date { public: int day;

C++//Step 1: Define a Public Class:
Declare a Date class with public members:
class Date
{
public:
int day; // Day of the Month
int month; // Month of the year
int year; // Year
};
Step 2: Create Objects:
Create Data Objects: In the main() function, create two objects of type Date: today and tomorrow. Assign values to today using the following statements:
today.day =26
today.month =4
today.year =2022
Use a cout statement to display the values of today.
(1 pt) Assign values to tomorrow in the same way.
Write the C++ code for this and insert the screenshot of the result here.
2.(1 pt) Change the access modifier of Date members from public to private and then compile the program. Briefly explain what happens when you try to access private members in main().
C + + / / Step 1 : Define a Public Class: Declare

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!