Correct
That is what is happening with you..I mean look at the main!
Code:
int main()
{
int d;
int m;
int y;
cout<<d<<"/"<<m<<"/"<<y;
return 0;
}
Where is the object of Date?You do not create any object here!You do not call the constructor!
This piece of code will create an object of class Date
and because you pass no arguments the default values are going to be assigned in the data members of the class(these are d,m,y).
The next step is to print the values of the data members of this object you just created?How are you going to do that?Two ways.Create a member function of class Date (with name print i would say) which would print the data members of the class when called.Or create getters for every data member of class and when going to write cout in main call this geters in order to take the value of the geter function.
An example of geter
Code:
class Date
{
private:
int month;
int day;
int year;
public:
Date (int=01, int=01, int=2013);
int getDay() { return day;}
};
using namespace std;
int main() {
Date dateObject();
int dayVariable = dateObject.getDay();
cout<<dayVariable<<endl;
return 0;
}