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.

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

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

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


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

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

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

This article has been dead for over six months. Start a new discussion instead.