Skip to content

Instantly share code, notes, and snippets.

@dibakarsutradhar
Created September 2, 2018 05:44
Show Gist options
  • Save dibakarsutradhar/d1ea2561e83293fb3983031b9f15af70 to your computer and use it in GitHub Desktop.
Save dibakarsutradhar/d1ea2561e83293fb3983031b9f15af70 to your computer and use it in GitHub Desktop.
A date program using struct
#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