#include<iostream.h>
#include<stdio.h>
class Account {
//private members cant be accessed outside class directly
private:
int accountNo,balance;
//instead use getter and setter methods to access variable
public:
void setAccountNo(int accountNo)
{
this->accountNo = accountNo;
}
void setBalance(int balance)
{
this->balance = balance;
}
int getAccountNo()
{
return (accountNo);
}
int getBalance()
{
return(balance);
}
} holder[10]; //creates 10 references of class account as an array
int main()
{
int i,accountNo,balance;
//this loop take the values in each object variables
for (i=0; i<10;i++)
{
cout<<"\nEnter account no for Account "<<i+1<<" :";
cin>>accountNo;
holder[i].setAccountNo(accountNo);
cout<<"\nEnter Balance for this account :";
cin>>balance;
holder[i].setBalance(balance);
}
for(i=0; i<10;i++)
{
if(holder[i].getBalance()>5000)
{
cout<<"\nAccount No :"<<holder[i].getAccountNo();
cout<<"\tBalance :'"<<holder[i].getBalance();
}
}
getchar();
return(0);
}
///////////////////////////
/* this will work surely but u might consider using file operations and be sure if u want to clear screen then include conio.h and use clrscr (though i wouldnt recommend doing this), my fingers are aching am quitting now*/
Quote:
|
Originally Posted by The_Devil_Himself
^^hey T159 can you debug this program and post the working one please.
|
done man