Skip to content

Instantly share code, notes, and snippets.

@juanfal
Created November 26, 2012 13:47
Show Gist options
  • Save juanfal/4148269 to your computer and use it in GitHub Desktop.
Save juanfal/4148269 to your computer and use it in GitHub Desktop.
Struct sample
// structsample.cpp
// juanfc 2011-12-08
//
#include <iostream>
using namespace std;
// types
enum TMonth { JAN, FEB, MAR, APR, MAY, JUN,
JUL, AUG, SEP, OCT, NOV, DEC };
struct TDate {
unsigned day;
TMonth month;
unsigned year;
};
struct TEmployee {
unsigned code;
float salary;
TDate joiningDate;
};
const TDate TODAY = {16, DEC, 2010};
int main()
{
TDate birthD, currD;
birthD = (TDate){19, AUG, 1960};
if (birthD == currD) {
cout << "Compared!" << endl;
}
TEmployee empl = {101, 2000, {19, AUG, 1960}};
empl.joiningDate.year++;
printMonth(empl.joiningDate.month);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment