Question
Can someone please help me. i keep getting an error in my code. I need it to be on three seperate files!
attached is my assignment and my code. c++
The class date Type implements the date in a program. Write the class functions as specified in the UML class diagram. The va
#ifndef DATETYPE H #define DATETYPE_H #include <cstring> class DateType private: int dDay: int Month; int dYear; public: date
#include <iostream> #include <dstring> #include DateType.h using namespace std; ype.cpp -.cpp int main() DateType g; g.getD
#include DateType.h #include <cstring> DateType::dateType() dDayl; dMonth-1; dYear-1; int DateType::getDate() return dDay:
if (dMonth--2) if (dDay 1 && dDay = 2 ) dDaydDay: dMonth-Month; dYear-dYear: else dDay=1; dMonth=dMonth; dYear-dYear: else if
else dDay : dMonth-1; dYear=1; else if (Day- 1 &dDay<- 30) dDay dDay: dMonth-dMonth; dYear-dYear: dDay 1: dMonth-1; dYear-1;
void DateType:: print Date() (cont <<dDay<</<<dMonth<</<dYear:) void DateType: :isLeapYear () if((dYear 4-=0) 66 (dYear:!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.)

prototype for 'void DataType::isLeapYear()' does not match any in class 'DataType'

You are getting this error because the return type of isLeapYear() during is actually int as per the declaration in line 25 of your class file but, while writing function definition for isLeapYear() in line 79, you have given the return type as void. Change line 25 of your class file to:
void isLeapYear();

2.)

candidate is: int DataType::isLeapYear()

you get this error because the function definition of isLeapYear() must be

int DataType::isLeapYear()

{

}

not

void DataType::isLeapYear()

{

}

because, the function declaration in line 25 if class file looks like

int isLeapYear();

However, this error must be gone once you have solved error 1.)

So, this must not be a problem.

3.)

'cout' was not declared in this scope

you get this error because, in class file there is a 'cout' inside printDate() function but the header file iostream was not included. cout is defined in iostream, so it is necessary to include iostream in whichever file cout is being used.

add this line at the beginning of the class file:

#include<iostream>

or alternatively,

you can just remove the definition of printDate() because i see that you are defining the function in the other file with all the function definitons.

That must clear the 3 errors being shown. If you need more information, please reach out to me in comment section.

Add a comment
Know the answer?
Add Answer to:
Can someone please help me. i keep getting an error in my code. I need it...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming Exercise 11-8 PROBLEM:The class dateType defined in Programming Exercise 6 prints the date in numerical...

    Programming Exercise 11-8 PROBLEM:The class dateType defined in Programming Exercise 6 prints the date in numerical form. Some applications might require the date to be printed in another form, such as March 24, 2019. Derive the class extDateType so that the date can be printed in either form. Add a member variable to the class extDateType so that the month can also be stored in string form. Add a member function to output the month in the string format, followed...

  • #include "stdafx.h" #include <iostream> using namespace std; class dateType {    private:        int dmonth;...

    #include "stdafx.h" #include <iostream> using namespace std; class dateType {    private:        int dmonth;        int dday;        int dyear;       public:       void setdate (int month, int day, int year);    int getday()const;    int getmonth()const;    int getyear()const;    int printdate()const;    bool isleapyear(int year);    dateType (int month=0, int day=0, int year=0); }; void dateType::setdate(int month, int day, int year) {    int numofdays;    if (year<=2008)    {    dyear=year;...

  • The class dateType is designed to implement the date in a program, but the member function...

    The class dateType is designed to implement the date in a program, but the member function setDate and the constructor do not check whether the date is valid before storing the date in the data members. Rewrite the definitions of the function setDate and the constructor so that the values for the month, day, and the year are checked before storing the date into the data members. Add a function member, isLeapYear, to check whether a year is a leap...

  • Hello, I have a bug in my code, and when I run it should ask the...

    Hello, I have a bug in my code, and when I run it should ask the user to enter the month and then the year and then print out the calendar for the chosen month and year. My problem with my code is that when I run it and I enter the month, it doesn't ask me for the year and it prints all the years of the month I chose. Please help! Code: #include "calendarType.h" #include <iostream> using namespace...

  • C++ problem 11-6 In Programming Exercise 2, the class dateType was designed and implemented to keep...

    C++ problem 11-6 In Programming Exercise 2, the class dateType was designed and implemented to keep track of a date, but it has very limited operations. Redefine the class dateType so that it can perform the following operations on a date, in addition to the operations already defined: Set the month. Set the day. Set the year. Return the month. Return the day. Return the year. Test whether the year is a leap year. Return the number of days in...

  • n this programming assignment, you need to create 3 files. 1. DateType.h 2. DateType.cpp 3. A...

    n this programming assignment, you need to create 3 files. 1. DateType.h 2. DateType.cpp 3. A test driver for testing the class defined in the other 2 files. You can name your file in the way you like. Remember it must be a .cpp file. In DateType.h file, type these lines: // To declare a class for the Date ADT // This is the header file DateType.h class DateType { public: void Initialize(int newMonth, int newDay, int newYear); int GetYear()...

  • Java Programming: Hi, I need help Modifying my code that will throw an IllegalArgumentException. for the...

    Java Programming: Hi, I need help Modifying my code that will throw an IllegalArgumentException. for the following data entry error conditions: A number less than 1 or greater than 12 has been entered for the month A negative integer has been entered for the year utilizes a try and catch clause to display an appropriate message when either of these data entry errors exceptions occur. Thank you let me know if you need more info import java.util.*; //Class definition public...

  • Can someone help me solve this problem? Everything works but I keep getting an error "expression...

    Can someone help me solve this problem? Everything works but I keep getting an error "expression must have a constant value". Its the Extended Euclidean Algorithm #include <iostream> using namespace std; #include<vector> void TwoLargest(int a[], int x) {    int largeOne = a[0];    int largeTwo = a[0];    for (int i = 1; i < x; i++)    {        if (a[i] > largeOne)        {            largeTwo = largeOne;            largeOne =...

  • Need help with the flow chart of this program #include #include using namespace std; string months[]...

    Need help with the flow chart of this program #include #include using namespace std; string months[] = {"January","February ","March","April","May","June","July","August","September","October","November","December"}; int days_in_months[] = {31,28,31,30,31,30,31,31,30,31,30,31}; class Date //Sample Class for the C++ Tutorial { private: int month; //Data member int day; // Data member int year; public: Date(int m, int d, int y) { if(m<1 || m >12) month = 1; else month = m; if(d<1 || d >days_in_months[month-1]) day = 1; else day = d; if(y<2001) year = 2001; else year...

  • Keep getting this error in my lab. Please help. Here is my cpp file and the...

    Keep getting this error in my lab. Please help. Here is my cpp file and the error given. Thank you 4 #include '10streat "Rationat . hi. .. Rational. cpp" 5 #include 6 :include Z using nanespace std 9 int sain) 11 char ch; 12 char op 13 Rational ri, r2, r3; 14 15 cout "nie lcome! I will evaluate expressions involving rational numbers for you 16 17 do 18 t 19 //Reading input 20 cout ee nEnter the expression (e.g.,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT