notes: must have a header file that has class birthday and its constructors (.h)
ID: 672854 • Letter: N
Question
notes: must have a header file that has class birthday and its constructors (.h)
second, must have a .cpp file that has function main and compareBDS ,( for loop where we search the age with the help of array).
You can post header file and .cpp file together
Note: The classes definitions should reside in separate header files. .Create a class called birthDay. The class should store the birthday of a person in three integers: month, day, and year. birthDay class has member functions to get these values and return them to the user. birthDay class takes the three values through the constructor. Outside the class, define a function called compareBDs that finds who is older among two persons. Create an array of four objects in the main function. Search the array to find the youngest person . Create an array of four objects in the main function.Explanation / Answer
#include<iostream.h>
#include<conio.h>
class birthDay
{
public:
int month,day,year;
birthDay(int m, int d, int y)
{
month =m;
day=d;
year=y;
}
int dd()
{
return day;
}
int mm()
{
return month;
}
int yy()
{
return year;
}
}
void compareBDs(birthDay o, birthDay o1)
{
if(o1.year>o.year)
{
cout<<"Second person is older";
}
else if(o1.year == o.year)
{
if(o1.month>o.month)
{
cout<<"Second person is older";
}
else
{
cout<<"First person older";
}
}
else
{
cout<<"First Person older";
}
}
void main()
{
birthDay obj(1,2,2001);
birthDay obj1(1,3,2002);
compareBDs(obj,obj1);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.