HELP! Bad Programmer!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2006
Posts: 2
Reputation: kevjeffers is an unknown quantity at this point 
Solved Threads: 0
kevjeffers kevjeffers is offline Offline
Newbie Poster

HELP! Bad Programmer!

 
0
  #1
Apr 13th, 2006
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:
  1. #ifndef dateSType_H
  2. #define dateSType_H
  3. //dateType name changed to dateSType
  4.  
  5. class dateSType
  6. {
  7. public:
  8. // ************ Mutators follow ************
  9. void setMM(int month);
  10. //Function to set the month.
  11. //The data members dMonth is set
  12. //according to the parameters.
  13. //Postcondition: dMonth = month;
  14. // default month = 01
  15.  
  16. void setDD( int day );
  17. //Function to set the month.
  18. //The data members dDay is set
  19. //according to the parameters.
  20. //Postcondition: dDay = day;
  21. // default day = 01
  22.  
  23. void setYY( int year);
  24. //Function to set the month.
  25. //The data members dYear is set
  26. //according to the parameters.
  27. //Postcondition: dYear = year;
  28. // default day = 1900
  29.  
  30.  
  31. void setDate(int month, int day, int year);
  32. //Function to set the date.
  33. //The data members dMonth, dDay, and dYear are set
  34. //according to the parameters.
  35. //Postcondition: dMonth = month; dDay = day;
  36. // dYear = year default 1900
  37. // default month = 01
  38.  
  39. //int getDay() const;
  40. //Function to return the day.
  41. //Postcondition: The value of dDay is returned.
  42.  
  43. //int getMonth() const;
  44. //Function to return the month.
  45. //Postcondition: The value of dMonth is returned.
  46.  
  47. //int getYear() const;
  48. //Function to return the year.
  49. //Postcondition: The value of dYear is returned.
  50.  
  51. void printDate() const;
  52. //Function to output the date in the form mm-dd-yyyy.
  53.  
  54. dateSType();
  55.  
  56. //dateSType(int month = 1, int day = 1, int year = 1900);
  57. //Constructor to set the date (Danger constructor here) #####
  58. //The data members dMonth, dDay, and dYear are set
  59. //according to the parameters.
  60. //Postcondition: dMonth = month; dDay = day; dYear = year
  61. //
  62. //If no values are specified, the default values are
  63. //used to initialize the data members.
  64.  
  65. private:
  66. int dMonth; //variable to store the month
  67. int dDay; //variable to store the day
  68. int dYear; //variable to store the year
  69. };
  70.  
  71. #endif

Implementation File:
  1. dateSType::dateSType() { }
  2. //default constructor
  3.  
  4.  
  5. dateSType::dateSType(int, int, int) { }
  6. //construct with parms
  7.  
  8. dateSType::~dateSType() {} //destructor
  9.  
  10. void dateSType::setDate(int month, int day, int year)
  11. {
  12. dMonth = month;
  13. dDay = day;
  14. dYear = year;
  15. }
  16.  
  17. void setMM(int month)
  18. {
  19. if ((month > 0 ) && (month < 13))
  20. dMonth = month; //valid month
  21. else
  22. dMonth = 1; //invalid month use default
  23. }

Here are my errors:
  1. 1>------ Rebuild All started: Project: ch13homework_8, Configuration: Debug Win32 ------
  2. 1>Deleting intermediate and output files for project 'ch13homework_8', configuration 'Debug|Win32'
  3. 1>Compiling...
  4. 1>ImpL_Lab8.cpp
  5. 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(1) : error C2653: 'dateSType' : is not a class or namespace name
  6. 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
  7. 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(1) : warning C4508: 'dateSType' : function should return a value; 'void' return type assumed
  8. 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(5) : error C2653: 'dateSType' : is not a class or namespace name
  9. 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
  10. 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(5) : warning C4508: 'dateSType' : function should return a value; 'void' return type assumed
  11. 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(8) : error C2653: 'dateSType' : is not a class or namespace name
  12. 1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(8) : fatal error C1903: unable to recover from previous error(s); stopping compilation
  13. 1>TestpgmLab8.cpp
  14. 1>Generating Code...
  15. 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"
  16. 1>ch13homework_8 - 6 error(s), 2 warning(s)
  17. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Sorry for the long post and thanks in advance for the help.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,606
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1490
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: HELP! Bad Programmer!

 
0
  #2
Apr 13th, 2006
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.
  1. #include "dateSType.h"
  2. // rest of cpp code here
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 164
Reputation: orko is an unknown quantity at this point 
Solved Threads: 10
orko orko is offline Offline
Junior Poster

Re: HELP! Bad Programmer!

 
0
  #3
Apr 14th, 2006
besides, u can write a test file to implement the functions one by one..... thus, u can understand which function is not working actually..... good luck!
A Perfect World
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 2
Reputation: kevjeffers is an unknown quantity at this point 
Solved Threads: 0
kevjeffers kevjeffers is offline Offline
Newbie Poster

Re: HELP! Bad Programmer!

 
0
  #4
Apr 14th, 2006
Thanks a lot guys.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC