Wednesday, August 27, 2008

Structures

Just messing around with structures, got this example from a book.
#include "stdafx.h"
#include
using namespace std;

int main()
{
//creating the structure
typedef struct {
char firstInitial;
char middleInitial;
char lastInitial;
int employeeNumber;
int salary;
} EmployeeT;

//Creating and Populating an Employee
//Employee Declaration
EmployeeT anEmployee;
//Building and Defining the Employee
anEmployee.firstInitial = 'M';
anEmployee.middleInitial = 'R';
anEmployee.lastInitial = 'G';
anEmployee.employeeNumber = 42;
anEmployee.salary = 317000;

//Output the values of an employee, in other words, assigns the values

//Prints the values to the screen
cout << "Employee: " << anEmployee.firstInitial <<
anEmployee.middleInitial <<
anEmployee.lastInitial << endl;
cout << "Number: " << anEmployee.employeeNumber << endl;
cout << "Salary: $" << anEmployee.salary << endl;


return 0;
}

No comments: