Hi Frank,
In a message of to All (), you wrote:
FM> I probably shouldn't do this but by posting this amateurish
FM> code some of the beginners some of my fellow hobbyists who are also
FM> trying to learn something might be encouraged or see something to
FM> criticize or make the basis for discussion. There are possibly
FM> bugs in it of which I'm still unaware as it's an ongoing sort of
FM> first real project for me.
Indeed, there is one dangerous thing in it, you call menu() while you are in
it, every time it eats some bytes from your stack. You should rewrite the
thing:
int menu()
{
do
{
........ the rest of your code
}
while(i != 5);
}
Some other things to look at:
You call the math-functions, after that you clear the screen and call the
menu that also starts to clear the screen, seems double to me.
When you call menu() from main() you should try to return to main where you
finish your program, so change the exit(0) in menu() to break and it will
leave your program normally.
FM> Kurt Kuzba was gracious enough to let me know about cprint
FM> and get me out of a bog so I could continue and I thank him
FM> enormously for that.
O.k. that was nice of Kurt, so I will give you lesson 2. Since you use cin,
which is the Object Oriented way to work with I/O, you should try to work
with constream to handle your screen-things; to show you what I mean, I'll
rewrite this part:
FM> clrscr();
FM> gotoxy(c,10);
FM> textcolor(14);
FM> cputs("Would you like to practice a little ");
to
constream con;
con << clrscr << setxy(c,10) << setclr(YELLOW) << "Would you like to practice
a little ";
Just read the constream.h and you'll find all screen-functions you need.
But now the most important thing, your code is not object oriented at all
(except for the use of cin). Since you write this message in the C++ area, I
suppose that you wanted to make an OOP-program. You could have made an object
Calculate in which you handle your 4 arithmatic-things. And when you finish
that, it should be very easy to add more arithmatic-functions (square root or
whatever you like) without copying a function and change some text and
operators.
Check some books about classes to understand what I mean.
Oh, BTW, the program worked, I only had to add one space between
.Division>.
FM> + Origin: Maybe in 5,000 years - frankmas@juno.com (1:396/45.12)
No, I think you can learn OOP in less time (-;
Regards,
Danny Springer.
(dsp@bitbike.com)
---
---------------
* Origin: Punt 12 uit Den Haag [NL] Point of AINEX (2:282/123.12@fidonet)
|