0
class Date
{
 public : Date();
          void getDate(int,string,int);
          
 private : int day;
           string mth;
           int year;

};//end class

//getdate
void Date::getDate(int& inDay,string& inMth,int& inYear) const //error here
{
 inDay=day;
 inMth = mth;
 inYear=year;
}

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.

3
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by Nick Evan
0

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&);

0

i have tried putting

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&)

0

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


#include <iostream>
#include <string.h>
using namespace std;

0

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

anyway:
Change the definition to void getDate(int&, string& ,int&) const;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.