Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
4003CEM-inheritance/lab_datetime.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
27 lines (23 sloc)
671 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef DATETIME_H | |
#define DATETIME_H | |
#include "lab_date.h" | |
#include "lab_time.h" | |
class DateTime: public Date, public Time | |
{ | |
public: | |
DateTime( int _day, int _month, int _year, | |
int _hour, int _min ) : | |
Date( _day, _month, _year ), // call the parent constructors | |
Time( _hour, _min ) | |
{} | |
void display() | |
{ | |
/* We can still call the methods from the parent even if they | |
have been overridden. We just have to explicitally state | |
that we want the display() method from Date or Time */ | |
Time::display(); | |
std::cout << "on" << std::endl; | |
Date::display(); | |
} | |
}; | |
#endif |