Hello. I'm trying to make a C++ program practices with classes and OOP with dates, using three files: main.cpp, Date.cpp, and Date.h. I'm getting errors in main.pp for undefined references and in Date.cpp. there is alse an error for undefined reference Requirements Date.h will contain the class declaration. The following is required in the class declaration: The private attributes are the month, day, and year. The public member functions are PrintDate, SetDate, and NextDate The default constructor should initialize all data to the value 0. NextDate should still return a new Date object with the next day's information. This function needs to be completed (For this, just assume Feb has 29 days all the time even though it is not true.) Date.cpp will contain the implementation of all member functions and the constructor main.cpp* will need to be updated to use the member functions. Example: SetDate(today,2,13,2016); // today.month = 2; // today.day = 13; // today.year = 2016; PrintDate(today); // should print 2/13/16 tomorrow = NextDate(today); Becomes today.SetDate(2,13,2016); today.PrintDate(); tomorrow = today.NextDate(); Date.h #ifndef DATE__H /* To prevent multiple inclusion problems */ #define DATE__H class Date { private: int month; int day; int year; public: void SetDate(int mo, int da, int yr); void PrintDate(Date date); Date NextDate(Date date); }; #endif Required Output: DateExample by student name 2/13/16 2/14/16 2/14/16 1/1/00 3/1/00 2/29/00 3/1/17 2/29/16 0/0/00
Hello. I'm trying to make a C++ program practices with classes and OOP with dates, using three files: main.cpp, Date.cpp, and Date.h. I'm getting errors in main.pp for undefined references and in Date.cpp. there is alse an error for undefined reference
Requirements
-
Date.h will contain the class declaration. The following is required in the class declaration:
- The private attributes are the month, day, and year.
- The public member functions are PrintDate, SetDate, and NextDate
- The default constructor should initialize all data to the value 0.
- NextDate should still return a new Date object with the next day's information. This function needs to be completed (For this, just assume Feb has 29 days all the time even though it is not true.)
-
Date.cpp will contain the implementation of all member functions and the constructor
-
main.cpp* will need to be updated to use the member functions. Example:
-
SetDate(today,2,13,2016);
// today.month = 2;
// today.day = 13;
// today.year = 2016;PrintDate(today); // should print 2/13/16
tomorrow = NextDate(today);
-
Becomes
Date.h
#ifndef DATE__H /* To prevent multiple inclusion problems */
#define DATE__H
class Date
{
private:
int month;
int day;
int year;
public:
void SetDate(int mo, int da, int yr);
void PrintDate(Date date);
Date NextDate(Date date);
};
#endif
Required Output:
DateExample by student name
2/13/16
2/14/16
2/14/16
1/1/00
3/1/00
2/29/00
3/1/17
2/29/16
0/0/00
Trending now
This is a popular solution!
Step by step
Solved in 8 steps with 4 images