parameter of a function to another class

hello programmers,

I'm trying to write two classes and make aggregation of the two classes: one to get one'd birthday and the other check if the bday is in certain range.


I have built the one getting bday so far as below:

Date.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 class Date{

public:
	Date();
	Date(int month, int day);
	
	int month() const;
	int day() const;
	void setMonth(int month);
	void setDay(int day);
private:
	int bdayMonth;
	int bdayDay;
};


Date.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

Date::Date() {
	bdayMonth = 0;
	bdayDay = 0;
}

Date::Date(int month, int day)
{
	bdayMonth = month;
	bdayDay = day;
}


void Date::setMonth(int month) 
{
	bdayMonth = month;
}
int Date::month() const {
	return bdayMonth;
}
void Date::setDay(int day) {
	bdayDay = day;
}
int Date::day() const {
	return bdayDay;
}


now I'm building another class that check if the bday is in certain range:

bdayCheck.h
1
2
3
4
5
6
7
8
9
10
11
12
13
class bdayCheck
{
public:
	bdayCheck();
	bdayCheck(Date date);
        
        enum valid{valid , invalid};
	bdayCheck::valid checkbday();

private:
	Date bdaydate;

};


bdayCheck.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
bdayCheck::bdayCheck()
{
	bdaydate;
}

bdayCheck::bdayCheck(Date date)
{
	bdaydate = date;			//date=(month, day)
}

bdayCheck::valid checkDate() {
	int a;
	if( month == 3 && day >=19 && day<=22 ) a=0;
	
        return a;
}



I know I cannot check each parameter from another class function date can be checked in this way but I don't know how I can check each parameter of date//
how should i build it?
Last edited on
now I'm building another class that check if the bday is in certain range:

that is the sole raison d'etre for the other class then you might as well just have a function returing bool and taking an argument of type Data that performs the same check
Topic archived. No new replies allowed.