123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|403|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> Book Study Sessions, Book 1, Week 1

Mon, 21 Sep 2009, 07:22
Afr0
Yeeay! I got my book.
This week we'll be covering two chapters! Introduction and Chapter 1.
If people are having trouble along the way, you post here (though I suspect it shouldn't be a problem since it's only the first chapter).
If not, I will post this week's challenge in this topic on Friday. Then during the weekend we can post solutions and ask questions and discuss which person managed to come up with the best solution.
I might even post a challenge of my own, depending on whether or not I have the time.
Also, if you still haven't decided upon a compiler, there's a link to downloading Microsoft Visual C++ Express Edition 2008 inside the book.

Edit: Uhm, Jay told me to mention that the book that was agreed upon was 'C++ Programming For The Absolute Beginner'. Most of us will be using the Second Edition, but I believe the first edition will also work. Except it teaches OpenGL for graphics related stuff. Which is just as well, as it is more industry-standard than DarkSDK used by the Second Edition.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Mon, 21 Sep 2009, 12:14
Afr0
Oh, right!
Well, it's still more industry standard than DarkSDK.

(That said, I could do with combining C++ with DarkSDK, as I suck at graphics programming)

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Wed, 23 Sep 2009, 04:18
CodersRule
I have the first edition with DirectX, although I'd do fine with learning OpenGL. Also, I have the CD for the first edition- if anyone needs the ISO, you can have it.
Wed, 23 Sep 2009, 05:13
Jayenkai
Not sure if that's legal. Does the book have a website with a downloadable version of the ISO?
If not, I wouldn't bother, probably not legal.

And anyway, if everyone's getting the book, it's kinda worthless 'cos they'll all have the CD anyway.


-=-=-
''Load, Next List!''
Fri, 25 Sep 2009, 09:44
Afr0
Here's my code for the first assignment. I had to format it a bit weirdly to make it look good on screen.



And the second assignment's output should be something like:

This is a test!
Test 1234
This is a test!


-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 25 Sep 2009, 09:55
Spare
Agent Smith found the solution in the back of the book for challenge 5 a bit strange, so did I. After showing my code and then later nesting those if statements this is what I made of it:

Fri, 25 Sep 2009, 10:05
Afr0
The code for assignment 3 (had to fiddle around to make this work):



Edit: If you're having trouble with assignment 5, look at Spare's code!!

The answer for question 4 is; No, you can't store 10.3 as an integer. I'm pretty sure you'll get a compile error if you try to do that. Or it'll be stored as 103.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 25 Sep 2009, 11:48
Spare
Strangely enough you're able to put 10.3 into an integer, it will just cut off the decimals but not error out

Question: afr0 why do you actually use "std::" instead of just using using "namespace std;" on top?
Fri, 25 Sep 2009, 12:00
Afr0

Question: afr0 why do you actually use "std::" instead of just using using "namespace std;" on top?


Dunno, I just got used to doing it that way.
It's kinda handy cos in Visual Studio you can see all the functions in std when you type ::

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 25 Sep 2009, 13:26
Spare
Nice work on challenge 5, Smith. I always forget it's possible to use ? :
Sat, 26 Sep 2009, 07:47
Phoenix
For the ones who are interested in pointless language details, I looked it up in the standard (section 4.9.1):

"An rvalue of a floating point type can be converted to an rvalue of an integer type. The conversion truncates; that is, the fractional part is discarded. The behavior is undefined if the truncated value cannot be represented in the destination type."

So it is indeed valid, although if you use the standard warning level, Visual Studio will give a warning if you try to initialize an integer with a floating point value.
Sat, 26 Sep 2009, 08:21
Afr0
The behavior is undefined


I've always wondered - what does it mean that a behaviour is undefined? Does it mean possible bugs that they haven't tested and can't be bothered to take responsibility for?

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sat, 26 Sep 2009, 08:24
Phoenix
It means that the compiler vendors don't have to conform to any standardized behaviour. In other words, it may work as you expect it to, or it won't, but either way the result might be different for users of another compiler. So don't rely on it.