| zimbabweo (2) | |
|
I'm learning to define classes. My first class program is not working. It's a simple program, just lets you enter a date, then sends it to cout. I get: "Error: identifier "cout" is undefined." I can see that error before I even attempt to compile by mousing over the squiggly red lines under cin and cout. I already have the iostream include in the cpp file, so I don't understand the cout and cin errors. And when I try to compile I get more errors: (29): error C2628: 'Date' followed by 'unsigned' is illegal (did you forget a ';'?) (29): error C2347: '__w64' : can not be used with type '__w64 Date' (29): error C2371: 'size_t' : redefinition; different basic types // *********************************************** // This is the .cpp file #include "Date.h" #include <iostream> #include <cstdlib> using namespace std; int main () { Date birthDate; cout << birthDate.enterDate (); return 0; } int Date::enterDate () { int inDate; cout << "Enter Date (mmddyyyy): "; cin >> inDate; return inDate; } // ************************************************ // This is the .h file #ifndef DATE_H #define DATE_H class Date { private: int date; public: Date () // constructor {date = 01012000;} int enterDate (); void printDate (); } #endif | |
|
|
|
| Peter87 (3691) | |
| You need a semicolon after the class definition. | |
|
|
|
| zimbabweo (2) | |
|
Peter87, That fixes it!! Thanks a lot. Now I just have to debug the rest of the functions...=) | |
|
|
|