Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
class date2019
{
private int m;
private int d;
public date2019(){
m=1;
d=1;
}

What I have tried:

class date2019{
private int m;
private int d;
public date2019(){
m=1;
d=1;
}
}
Posted
Updated 19-Oct-19 11:32am

1 solution

Change your constructor:
C#
class date2019
    {
    private int m;
    private int d;
    public date2019(int month = 1, int day = 1)
        {
        m = month;
        d = day;
        }
    }
Now when you construct and instance with the new keyword you can supply the month and day, or optionally omit them and they will default to January 1st.
 
Share this answer
 

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