incomplete type is not allowed error

so this is the only error i have in my code but i cant figure out how to fix it, here is the code below. note its broken into 3 files.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//date.cpp
#include <iostream> 
using namespace std; 
#include "date.h"


Date::Date(int m, int d, int y)
{

if(m<=12 && d<= 31 && y<=2500)
{
	mth=m,day=d,yr=y;
}
  

else
{
mth = 0;
day = 0;
yr =1000;

}


};



void Date::printDate()
{
	cout<<mth<<"/"<<day<<"/"<<yr<<endl;


}


//test.cpp
 
/* Insert any #include directives you need here*/
#include <iostream>
using namespace std;
#include "date.h"
void setDateValues (int&, int&, int&);

int main()
{
   int mth, day, yr;
   setDateValues (mth, day, yr);
   /* Create a Date instance from the user input here*/
   Date day1(int mth,int day,int yr);
  
   cout << "Date is:"<<endl;
  /* Call your print function 3 separate times to test print the date in each of 3 formats */
    void day1.printDate(); 
	
}
 
// SetDateValues obtains the user input in this test driver -- NOT in the Date class
//   implementation file 
void setDateValues (int& m, int& d, int& y)
{
   cout << "Enter month: ";
   cin >> m;
   cout << "Enter day: ";
   cin >> d;
   cout << "Enter year: ";
   cin >> y;
}

//date.h
#include <string> 
using namespace std; 
class Date { 
private:
int mth, day, yr;



public: 

Date(int,int,int);
void printDate(); 
};














error occurs in test.cpp, it highlight the day1
Last edited on
Please, show the definition of class Date.

I am sorry. I have seen it. It shall be before the main. That is this part of code

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <string> 
using namespace std; 
class Date { 
private:
int mth, day, yr;



public: 

Date(int,int,int);
void printDate(); 
};


shall be in header "date.h"

Also instead of

Date day1(int mth,int day,int yr);
shall be

Date day1(mth, day, yr);
Last edited on
i switched to
Date day1(mth,day,yr);
but inside test.cpp the Date day1(mth,day,yr); day1 is highlighted and i still get the same error
What is the content of "date.h"?
A am sorry. Please show anew your test.cpp with your updates.
Last edited on
Topic archived. No new replies allowed.