Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
void retrieveDate(int &, int &, int &) const;


What I have tried:

void Date::retrieveDate(int &a, int &b, int &c) const
{
Day = a; Month = b; Year = c;
}
what should I do to? like I want to retrieve parameters into class private members
Posted
Updated 1-Dec-20 7:22am
v2
Comments
Rick York 1-Dec-20 13:50pm    
Your question is unclear. I think the word "retrieve" is being used incorrectly It also means to get so if I call a function that gets a date I do not expect that to set the values of any class members. I call that setting the parameters.

Also, it is a bad idea to declare a function or method prototype with no variable names. All we know is it takes three integers but what they mean? Are they year, month, date, or d/m/y as Americans like to write?
NaumanMalik 1-Dec-20 14:03pm    
#include<iostream>
using namespace std;

class Date
{
bool validateDate(); // Validate attribute range values – methods can also be private. You can use this to check validity.
int Day;
int Month;
int Year;
public:
Date(); // initialize attributes with default values
~Date();
Date(int, int, int);// if invalid, set default date or set equal to system date
Date(const Date &);
bool inputDate(); /* assign values to Date attributes (cin from user),
return true if valid range of values are input */
bool copyDate(Date &); // return true if date was valid and copied successfully.
bool inputCompleteDate(int, int, int); // return true if date was valid and was set successfully.
Date &getDate() const;
void retrieveDate(int &, int &, int &) const; // retrieve Date attribute values
void showDate() const; // Display Date attribute values
bool isEqual(Date &); // return true if both dates are equal, (hint: one is already present as this pointer)
int daysBetween(Date &); // return days elapsed between two Dates
int operator - (Date &); // return days elapsed between two Dates. Yes its above function but with operator overloading
// All other relevant methods go here, setter/getter etc

};
this is my question to write bodies of functions of this header file and implement it in main.cpp... I think you will get the question, if not then I can't have anything else to state... i asked my teacher about this... he said you have to set values

I also tried this way but it is also giving errors:
void Date::retrieveDate(int &a, int &b, int &c) const Day(a), Month(b), Year(c);
{

}
Dave Kreskowiak 1-Dec-20 14:55pm    
How on earth should anyone but you know what needs to go in there? You're the one writing the code and should know what that function should be doing! Nobody else on the planet knows what you want this code to do!
NaumanMalik 1-Dec-20 15:01pm    
I'm really sorry if I'm not clearing my point. Actually it is my assignment question and I am writing its code but I am unable to figure out how am I going to retrieve date attributes
void retrieveDate(int &, int &, int &) const; // retrieve Date attribute values
like this in above reply ....You can't even change the prototype...
Dave Kreskowiak 1-Dec-20 16:45pm    
This is homework so you're not getting any code.

I think it's pretty clear what this function is supposed to do. It should set the values of the three variable passed in to whatever the date values are in this instance of the class.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900