Thread: illegal error

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    19

    Question 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

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    43
    Is date.h standard header? It is not known by MS Visual C++
    If it is your own, please give the source

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    19
    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

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    43
    You have forgotten ";"
    class Data
    {
    ....
    }

    Should be:
    class Data
    {
    ....
    };

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    19

    lol

    omg duh! that was pretty dumb.. it was killin me.. lol
    thx!!

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    43
    Do not worry! I have made this mistake a lot of times

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  4. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM