| | |
HELP! Bad Programmer!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2006
Posts: 2
Reputation:
Solved Threads: 0
I need help. Here is the homework problem:
Write the definitions of the functions to implement the operators defined for the class dateType.
Here's my code:
Header:
Implementation File:
Here are my errors:
Sorry for the long post and thanks in advance for the help.
Write the definitions of the functions to implement the operators defined for the class dateType.
Here's my code:
Header:
C++ Syntax (Toggle Plain Text)
#ifndef dateSType_H #define dateSType_H //dateType name changed to dateSType class dateSType { public: // ************ Mutators follow ************ void setMM(int month); //Function to set the month. //The data members dMonth is set //according to the parameters. //Postcondition: dMonth = month; // default month = 01 void setDD( int day ); //Function to set the month. //The data members dDay is set //according to the parameters. //Postcondition: dDay = day; // default day = 01 void setYY( int year); //Function to set the month. //The data members dYear is set //according to the parameters. //Postcondition: dYear = year; // default day = 1900 void setDate(int month, int day, int year); //Function to set the date. //The data members dMonth, dDay, and dYear are set //according to the parameters. //Postcondition: dMonth = month; dDay = day; // dYear = year default 1900 // default month = 01 //int getDay() const; //Function to return the day. //Postcondition: The value of dDay is returned. //int getMonth() const; //Function to return the month. //Postcondition: The value of dMonth is returned. //int getYear() const; //Function to return the year. //Postcondition: The value of dYear is returned. void printDate() const; //Function to output the date in the form mm-dd-yyyy. dateSType(); //dateSType(int month = 1, int day = 1, int year = 1900); //Constructor to set the date (Danger constructor here) ##### //The data members dMonth, dDay, and dYear are set //according to the parameters. //Postcondition: dMonth = month; dDay = day; dYear = year // //If no values are specified, the default values are //used to initialize the data members. private: int dMonth; //variable to store the month int dDay; //variable to store the day int dYear; //variable to store the year }; #endif
Implementation File:
C++ Syntax (Toggle Plain Text)
dateSType::dateSType() { } //default constructor dateSType::dateSType(int, int, int) { } //construct with parms dateSType::~dateSType() {} //destructor void dateSType::setDate(int month, int day, int year) { dMonth = month; dDay = day; dYear = year; } void setMM(int month) { if ((month > 0 ) && (month < 13)) dMonth = month; //valid month else dMonth = 1; //invalid month use default }
Here are my errors:
C++ Syntax (Toggle Plain Text)
1>------ Rebuild All started: Project: ch13homework_8, Configuration: Debug Win32 ------ 1>Deleting intermediate and output files for project 'ch13homework_8', configuration 'Debug|Win32' 1>Compiling... 1>ImpL_Lab8.cpp 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(1) : error C2653: 'dateSType' : is not a class or namespace name 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(1) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(1) : warning C4508: 'dateSType' : function should return a value; 'void' return type assumed 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(5) : error C2653: 'dateSType' : is not a class or namespace name 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(5) : warning C4508: 'dateSType' : function should return a value; 'void' return type assumed 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(8) : error C2653: 'dateSType' : is not a class or namespace name 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(8) : fatal error C1903: unable to recover from previous error(s); stopping compilation 1>TestpgmLab8.cpp 1>Generating Code... 1>Build log was saved at "file://c:\Documents and Settings\d2434login\My Documents\Visual Studio 2005\Projects\ch13homework_8\ch13homework_8\Debug\BuildLog.htm" 1>ch13homework_8 - 6 error(s), 2 warning(s) ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Sorry for the long post and thanks in advance for the help.
you forgot to include the header file in the *.cpp file. You may also need other header files too, such as iostream, fstream, string, etc. depending on your code.
C++ Syntax (Toggle Plain Text)
#include "dateSType.h" // rest of cpp code here
![]() |
Similar Threads
- PLEASE HELP about Using C# to add an executable file to my program! (C#)
- Project Help: Growth of a Function (Java)
- Need Help Screening a Programmer (Computer Science)
- Timesaving Tips (C++)
- Read unlimited no. of people. (C)
- help me to correct this part of my program (C++)
Other Threads in the C++ Forum
- Previous Thread: Sorting a 2d array of strings in C++??
- Next Thread: Create a pattern..Please help!
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph homeworkhelp iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






