Can you guys help me with my assignment Thank you It is in c
Can you guys help me with my assignment? Thank you
It is in c++
------------
Create the following classes:
Date:
-Dom (int)
-Month (int)
-year (int)
-Constructor of the form Date (int, int, int)
Event
-date(date)
-description(string)
-constructor of the form Event(string, int, int, int)
—use a constructor initialization list
-constructor of the form Event (string, Date)
—use a constructor initialization list
-use the class in main
-prompt the user for
-event name
-date, month, year
-instantiate two Event objects and initialize with the data provided
-each instance should use a different constructor
-use overloaded<<operator to display information for both objects
-ie. cout<<event1<<endl;
cout<<event2<<endl;
Solution
#include <iostream>
 using namespace std;
class Date //date class
 {
    private:
    int day;
    int month;
    int year;
    public:
    Date(int d,int m,int y) //constructor
    {
        day=d;
        month=m;
        year=y;
    }
    friend ostream &operator<<( ostream &output,
 const Date &D )   
 { //overloaded function
 output << \"Date : \" << D.day<<\"/\"<<D.month<<\"/\"<<D.year;
 return output;
 }
 };
 class Event //Event class
 {
    private:
    Date* date; //pointer to Date class
    string description;
    public:
    Event(string desc,int d,int m,int y)
    {
        date = new Date(d,m,y);
    description =desc;
   
    }
    Event(string desc,Date d)
    {
        date = &d;
    description =desc;
   
    }
    friend ostream &operator<<( ostream &output,
 const Event &E )
 {
 output << \"\ Event : \" << E.description ;
 return output;
 }
  
 };
 int main()
 {
    string eventName;
    int day,month,year;
    cout<<\"\ Enter the event name\";
    cin>>eventName;
    cout<<\"\ Enter day month and year\";
    cin>>day>>month>>year;
   
    Date date(day,month,year) ;
    Event Event1(eventName,day,month,year);
    Event Event2(eventName,date);
   
    cout<<\"\ Event 1:\"<<Event1<<date<<endl;
    cout<<\"Event 2:\"<<Event2<<date;
   
    return 0;
 }
output:
Success time: 0 memory: 3476 signal:0



