🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

C++ Workshop - Functions, Parameters, & Scope (Ch. 5)

Started by
45 comments, last by me_minus 14 years, 10 months ago
It's difficult for editors to proof read code. :)
Advertisement
I mentioned some typos a while ago and wondered at that stage if they could be fed back to improve the next edition. I don't know how many of us are here following the weekly threads, but the book is being reviewed systematically so wouldn't it be logical for comments to be passed on? I appreciate that editors may find it difficult to see errors in code, so why not "use" the help that we might be able to offer via this forum?

Even if detailed comments weren't fed back, it would be possible to bring this workshop to the attention of the authors and editors so they could go through the comments that have been raised.
Quote: Original post by CondorMan
I mentioned some typos a while ago and wondered at that stage if they could be fed back to improve the next edition. I don't know how many of us are here following the weekly threads, but the book is being reviewed systematically so wouldn't it be logical for comments to be passed on? I appreciate that editors may find it difficult to see errors in code, so why not "use" the help that we might be able to offer via this forum?

Even if detailed comments weren't fed back, it would be possible to bring this workshop to the attention of the authors and editors so they could go through the comments that have been raised.


One should be able to contact the author of the book if there are some contact informations available - or simply contact the book editor (don't be affraid by them - they are kind and respectful; after all, you are their customers) to get in touch with the author.

Regards,
Hello all,

I've started the workshop 3 days ago and I'm trying to catch up... although it will be a bit hard :).

I'm currently finishing chapter 5... and I'm trying to catch up ...

Great work on the workshop by the way! If it wasn't for this
I wouldn't have started on this quest to learn C++!

// This post has been edited after I saw how big a fool I was
// for making the foolish question I made =P
No question is too foolish.. at least in my book. :)
were the answers for these questions posted somewhere? :D
Which questions?
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints
Quote: Original post by Alphabat
Hello all,

I've started the workshop 3 days ago and I'm trying to catch up... although it will be a bit hard :).

I'm currently finishing chapter 5... and I'm trying to catch up ...

Great work on the workshop by the way! If it wasn't for this
I wouldn't have started on this quest to learn C++!


I am in the same boat so I quote the above :)

I was working on chapter five and I typed in the code from listing 5.2 (converting Fahrenheit to Celsius) and I keep getting an error:

// Practice#include<iostream>float Convert(float);  //function prototypeint main(){		float tempFer;	float tempCel;		std::cout << "\nPlease enter a temp in Fahrenheit: ";	std::cin >> tempFer;	std::cout << "\nHere is the temp in Celsius: ";	std::cout << tempCel << std::endl;		return 0;}float Convert(float tempFer){	float tempCel;	tempCel = ((tempFer - 32) * 5) / 9;	return tempCel;}


The error I get is:

e:\documents and settings\dave\my documents\visual studio 2005\projects\practice\practice\practice.cpp(16) : warning C4700: uninitialized local variable 'tempCel' used

I can't figure out the problem, I tried initializing it to '0' but then the function always returns '0' :(

Nevermind, I figured it out, I forgot to call the function :p ...


// Practice#include<iostream>float Convert(float);  //function prototypeint main(){		float tempFer;	float tempCel;		std::cout << "\nPlease enter a temp in Fahrenheit: ";	std::cin >> tempFer;        tempCel = Convert(tempFer); // Forgot this :(	std::cout << "\nHere is the temp in Celsius: ";	std::cout << tempCel << std::endl;		return 0;}float Convert(float tempFer){	float tempCel;	tempCel = ((tempFer - 32) * 5) / 9;	return tempCel;}
I actually was wondering if you guys could help me out with the information about stacks. Lemme see if I get this right:

I will use the graphic on page 132 as reference.
As I understand it, std::endl clears the stack yes? So using std::endl during
the current situation depicted on page 132 would clear away the "off the stack" portion yes? Has this information already been used? Does it still need to be used? I fail to understand how putting new information on the top of stack would get used then.

->Forgive my being many chapters behind, just started this. Thanks for this though, awesome stuff guys!
Hi guys,

Just wanted to ask about a part of the text in the book that goes like this:

Page. 130 Last paragraph states the following and I quote

Quote:
Last-in, first out means that whatever is added to the stack last is the first thing taken off. This differs from most queues in which the first in is the first out (like a line at the theater).


Shouldn't the queues be first in, last out?

Meaning:
Stack: First in, First out 'FiFo'
Queu: First in, Last out 'FiLo'?

By the way, JWalsh, if your reading this, congratulation on your son, I know it's late, but, better late then never right.


Edited: due to additional question.

Exercise:5_6

Using the call to a function as an expression? Is that often done or good coding habit?

[source = C++]// Example(s) and exercise(s) from the book: Sams Teach Yourself// Authors: Jesse Liberty and Bradley Jones// Combination with the online tutorial classes from Jeromy Walsh on Gamedev.#include <iostream>double Division(unsigned short int num1, unsigned short int num2);int main(){	double result;	if ((result = Division(0, 1)) == -1) // <--- this part???		std::cout << "Dividing by zero is not possible!" << std::endl;	else		std::cout << result << std::endl << std::endl;			char ch;	std::cout << "\nQuit program by pressing any letter or number!\n";	std::cin >> ch;	return 0;}double Division(unsigned short int num1, unsigned short int num2){	if (num2 == 0)		return -1;	else		return num1/num2;}


[Edited by - J0Be on May 20, 2007 9:36:10 AM]

This topic is closed to new replies.

Advertisement