(a) [15%] Implement a class named "Event" that satisfies all of following requirements: i) The class has the following data members - id: An integer - name: A string that represents the name of the event - start, end: The starting and ending times ofthe event. We assume all events starts and ends in the same day.
ii) The class has two constructors a) A default constructorJa constructor with no parameters) that sets the data members to the following values: Data members Initial values Id 0
Name
"No name"
start, end
Both represent the time 00:00:00.
Here from the above part how to use start and end time with the base class construtor
Mine code is
Expand|Select|Wrap|Line Numbers
- #include<iostream>
- #include<string.h>
- using namespace std ;
- class Time {
- public:
- int hh, mm, ss;
- Time(){
- hh =mm =ss =0;
- }
- // friend class Event;
- Time :: Time(int h, int m, int s)
- {
- hh=h;
- mm=m;
- ss=s;
- }
- };
- class Event : public Time
- {
- public:
- int id ;
- char name[10] ;
- float start ;
- float End;
- Event(){
- id = 0;
- strcpy(name, "Hi");
- start = 0.0 ;
- End = 0.0 ;
- }
- // Event();
- Event(int id1, char name1[],float start1, float end1){
- id = id1 ;
- strcpy(name,name1);
- start = start1 ;
- End = end1 ;
- cout<<id<<endl<<start<<endl<<name<<endl<<End<<endl ;
- //cout<<"Done"<<endl ;
- }
- };
- int main(){
- Event e ;
- Event(300, "hi",3.0 , 9.0) ;
- return 0 ;
- }