Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

class usage

Status
Not open for further replies.

cachaffee

Programmer
Jul 23, 2000
2
US
I am learning to use classes.&nbsp;&nbsp;I have been asked to create a class called SavingsAccount, which contains a static data member annualInterestRate and a private data member savingsBalance.&nbsp;&nbsp;I need to utilize a member function calculateMonthlyInterest to calculate the interest on savingsBalance.&nbsp;&nbsp;I also need to use a member function modifyInterestRate to adjust the static interest rate.&nbsp;&nbsp;I need to use these member functions with two objects of class SavingsAccount to calculate the interest earned on two different accounts, saver1 and saver2.&nbsp;&nbsp;I am a little confused.&nbsp;&nbsp;If I can be helped, please email me, I will send what code I have and we can go from&nbsp;&nbsp;there.<br><br>Thanks...
 
Ok lets see if i get this straight, basically this is the outline you have:<br><br><FONT FACE=monospace><font color=blue><br>Class SavingsAccount<br>{<br>public:<br>static float annualInterestRate; //I assume it's a float<br>private:<br>float savingBalance;<br>};<br></font></font><br><br>but you want something like, this I assume when it comes to the functions<br><br><FONT FACE=monospace><font color=blue><br>Class SavingsAccount<br>{<br>public:<br>static float annualInterestRate; //I assume it's a float<br>void moidifyInterestRate(float newrate); //assume it doesnt return either<br>private:<br>float savingBalance;<br>};<br></font></font><br><br>and you get this from setting up.<br><br><FONT FACE=monospace><font color=blue><br>SavingsAccount saver1, saver2;<br><br><i>/* assuming you created both above, since annualInterestRate is a static, if you change it in saver1, it get changed in saver2, only one copy of a static variable exist, no matter how many objects you have, other variables however, are duplicated in their own memory space, so ballance of each may be different, but not the interest rate. */</i><br></font></font><br><br><br>Assuming I got this much correct, what do you need help with? <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
Karl,<br><br>I sent you an email detailing the scenario more completely than my posting.&nbsp;&nbsp;I believe that it will make clear where my confusion is.<br><br>Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top