Created
September 2, 2018 05:44
-
-
Save dibakarsutradhar/d1ea2561e83293fb3983031b9f15af70 to your computer and use it in GitHub Desktop.
A date program using struct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct DateStruct { | |
int year; | |
int month; | |
int day; | |
}; | |
void print (DateStruct &date) { | |
cout << date.year << "/" << date.month << "/" << date.day << endl; | |
} | |
int main(){ | |
DateStruct today { 2018, 9, 1 }; // use unifrom initialization | |
today.day = 2; // use member selection oparetor to select a member of the struct | |
print(today); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment