943,718 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2009
  • C++ RSS
Nov 12th, 2008
0

Error with getDate function

Expand Post »
C++ Syntax (Toggle Plain Text)
  1. class Date
  2. {
  3. public : Date();
  4. void getDate(int,string,int);
  5.  
  6. private : int day;
  7. string mth;
  8. int year;
  9.  
  10. };//end class
  11.  
  12. //getdate
  13. void Date::getDate(int& inDay,string& inMth,int& inYear) const //error here
  14. {
  15. inDay=day;
  16. inMth = mth;
  17. inYear=year;
  18. }

I'm doing up a date class. Am doing a class function getDate to return back the day,mth and year through a reference variable. I am getting a compilation error and have been staring at my codes for a while. Can't seem to find where went wrong.

Could someone give me a help here please?

error message was, "void Date::getDate(int&, std::string&, int&) const' does not match any in class `Date' " and void Date::getDate(int, std::string, int)

Many thanks.
Similar Threads
Reputation Points: 6
Solved Threads: 0
Light Poster
AcidG3rm5 is offline Offline
25 posts
since Oct 2008
Nov 12th, 2008
0

Re: Error with getDate function

The function prototype in the class does not have the same identical type parameters as in the implementation code. Change go void getDate(int&, string& ,int&);
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Nov 13th, 2008
0

Re: Error with getDate function

i have tried putting
C++ Syntax (Toggle Plain Text)
  1. void getDate(int&, string& ,int&);

am still getting a compilation error. any other solution ?

error message is prototype for `void Date::getDate(int&, std::string&, int&) const' does not match any in class `Date'

void Date::getDate(int&, std::string&, int&)
Last edited by AcidG3rm5; Nov 13th, 2008 at 7:07 am.
Reputation Points: 6
Solved Threads: 0
Light Poster
AcidG3rm5 is offline Offline
25 posts
since Oct 2008
Nov 13th, 2008
0

Re: Error with getDate function

you forgot to add the "const" keyword after the definition
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Nov 13th, 2008
0

Re: Error with getDate function

re-read my previous post
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Nov 13th, 2008
0

Re: Error with getDate function

btw..if it helps. i only included these in my program.


#include <iostream>
#include <string.h>
using namespace std;
Reputation Points: 6
Solved Threads: 0
Light Poster
AcidG3rm5 is offline Offline
25 posts
since Oct 2008
Nov 13th, 2008
0

Re: Error with getDate function

Hmm, that weird, my answer to your post appears above the post...

anyway:
Change the definition to
void getDate(int&, string& ,int&) const;
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Help on begginer project
Next Thread in C++ Forum Timeline: Compiling in VC++ 2008 Express





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC