-
illegal error
why am i gettin this error?
Compiling...
proj5.cpp
C:\Windows\Desktop\c++2\lab6\proj5\proj5\proj5.cpp (6) : error C2628: 'Date' followed by 'int' is illegal (did you forget a ';'?)
Error executing cl.exe.
for this code:
#include <iostream>
using namespace std;
#include "date.h"
int main()
{
Date d1, d2;
int d, m, y;
d1.setMonth(12);
d1.setDay(01);
d1.setYear(01);
d1.setMonth2(12);
d1.setDay2(01);
d1.setYear2(01);
cin>>m;
cin>>d;
cin>>y;
d2.setMonth(m);
d2.setDay(d);
d2.setYear(y);
d2.setMonth2(m);
d2.setDay2(d);
d2.setYear2(y);
return 0;
}
thanks
Raz
-
Is date.h standard header? It is not known by MS Visual C++
If it is your own, please give the source
-
the error occurs when i compile the previous mentioned code on is own.. w/o linkin it..
but here is the code for date.h
#ifndef DATE_H
#define DATE_H
#include <iostream>
#include <cstring>
using namespace std;
class Date
{
friend ostream& operator<<(ostream&,const Date &);
friend iostream& operator>>(istream&, Date&);
public:
Date(int=0,int=0,int=0);
void setMonth(const Date&);
void setDay(const Date&);
void setYear(const Date&);
void setMonth2(const Date&);
void setDay2(const Date&);
void setYear2(const Date&);
//const Date &operator=(const Date &)const;
bool operator==(const Date& right)const;
bool operator!=(const Date& right)const
{return !(*this==right);}
private:
int month;
int day;
int year;
}
#endif
lemmie kno if you need the implementation file too
-
You have forgotten ";"
class Data
{
....
}
Should be:
class Data
{
....
};
-
lol
omg duh! that was pretty dumb.. it was killin me.. lol
thx!!
-
Do not worry! I have made this mistake a lot of times :)