Error with getDate function

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

Join Date: Oct 2008
Posts: 16
Reputation: AcidG3rm5 has a little shameless behaviour in the past 
Solved Threads: 0
AcidG3rm5 AcidG3rm5 is offline Offline
Newbie Poster

Error with getDate function

 
0
  #1
Nov 12th, 2008
  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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,500
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: 1479
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Error with getDate function

 
0
  #2
Nov 12th, 2008
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&);
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 16
Reputation: AcidG3rm5 has a little shameless behaviour in the past 
Solved Threads: 0
AcidG3rm5 AcidG3rm5 is offline Offline
Newbie Poster

Re: Error with getDate function

 
0
  #3
Nov 13th, 2008
i have tried putting
  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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,927
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 304
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: Error with getDate function

 
0
  #4
Nov 13th, 2008
you forgot to add the "const" keyword after the definition
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,927
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 304
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: Error with getDate function

 
0
  #5
Nov 13th, 2008
re-read my previous post
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 16
Reputation: AcidG3rm5 has a little shameless behaviour in the past 
Solved Threads: 0
AcidG3rm5 AcidG3rm5 is offline Offline
Newbie Poster

Re: Error with getDate function

 
0
  #6
Nov 13th, 2008
btw..if it helps. i only included these in my program.


#include <iostream>
#include <string.h>
using namespace std;
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,927
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 304
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: Error with getDate function

 
0
  #7
Nov 13th, 2008
Hmm, that weird, my answer to your post appears above the post...

anyway:
Change the definition to
void getDate(int&, string& ,int&) const;
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



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC