|
-
March 13th, 2014, 10:20 PM
#1
class constructor to create date and time
Write your question here.
im trying to create two classes: a Date class and a Time class. The Date class has to have three private data members: day, month and year. The Time class should have two private data members: hour and minute. Each class should have two member functions: a constructor and display.
im lost and my code won't run
class Date {
private:
int month, day, year;
public:
Date(int m, int d, int y){
month = m;
day = d;
year = y;
}
};
#endif
#include<iostream>
#include "Date.h"
Date::
void Date: isplay( int m, int d, int y)
{
month = m;
day = 0;
year = y;
cout<<month<<" "<<date<<", "<<year<<endl;
}
#include "Date.h"
#include "Time.h"
int main()
{
Date dt(7,4,1776);
Time tm(12,3);
dt.display();
tm.display();
return 0;
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|