Structures

I'm trying to understand an example program from a book but there's a line of code that I can't understand what is for. Can anybody tell me. Thanks


#include "stdafx.h"
#include<iostream>
using namespace std;

// structure for a bank certificate of deposit:
struct CDAccountV1
{
double balance;
double interestRate;
int term;//months until maturity
};

void getData(CDAccountV1& theAccount);
//postcondition: theAccount.balance, theAccount.interestRate and
// the Account.term have been given values that the user entered at the keyboard.

int main()
{
CDAccountV1 account;//<--------------------------------THIS ONE
getData(account);

double rateFraction, interest;
rateFraction=account.interestRate/100.0;
interest=account.balance*(rateFraction*(account.term/12.0));
account.balance=account.balance+interest;


cout<<"When your CD matures in "
<<account.term<<" months.\n"
<<"it will have a balance of $"
<<account.balance<<endl;
return 0;
}
//uses iostream;

void getData(CDAccountV1& theAccount1)
{
cout<<"Enter account balance: $";
cin>>theAccount1.balance;
cout<<"Enter account interest rate: ";
cin>>theAccount1.interestRate;
cout<<"Enter the number of months until maturity: ";
cin>>theAccount1.term;
}


It declares account as an instance of CDAccountV1. Instances/objects are to classes as variables are to types.
Last edited on
Topic archived. No new replies allowed.