Skip to content

Instantly share code, notes, and snippets.

@KennFatt
Forked from dibakarsutradhar/date.cpp
Created September 2, 2018 06:05
Show Gist options
  • Save KennFatt/ab4a2c8970e946ae81c9a27816f40bc7 to your computer and use it in GitHub Desktop.
Save KennFatt/ab4a2c8970e946ae81c9a27816f40bc7 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