Original Post
Welcome to the GDNet C++ Workshop – Ch. 4
For a complete introduction to this workshop, please look here. Workshop Overview This workshop is designed to aid people in their journey to learn beginning C++. This workshop is targeted at highly motivated individuals who are interested in learning C++ or who have attempted to learn C++ in the past, but found that without sufficient support and mentoring they were unable to connect all the pieces of this highly complex but powerful programming language. This is a 'guided' self-teaching C++ workshop. Each student is responsible for taking the time to read the material and learn the information. The community and tutors that arise out of this workshop are here for making the learning process run more smoothly, but are not obligated to baby-sit a person's progress. Because everyone will be working from the same textbook (Teach Yourself C++ in 21 days 5th Ed.), students may find it easier to get answers to the specific questions they might have. There is no minimum age requirement, and there is no previous programming experience required. Additionally, this workshop does not attempt to defend C++ as a language, nor does it attempt to demonstrate that C++ is either more or less useful then other programming languages for any particular purpose. People who intend to start a discussion about the differences between C++ and ANY other languages (except as are relevant to a particular discussion), are encouraged to do so elsewhere. This workshop is for educational, not philosophical discussions. Quizzes & Exercises Each week will have quizzes and exercises posted in the weekly threads. Please try and answer them by yourself. As well, please DO NOT post the answers to Quizzes and Exercises within this thread. Once it becomes acceptable to post the answers to quizzes and exercises, an additional thread will be created each week specifically for the purpose of posting quiz answers. If you try with reasonable effort but are unable to answer the questions or complete the exercises, feel free to post a clarification question here on the thread. Tutors, myself, or others will do the best we can to point you in the right direction for finding the answer.Chapter 4 – Creating Expressions and Statements
Introduction Greetings! Welcome to what might be considered the most fundamental chapter in the book - expressions and statements. Although basic layout and variables are an integral part of C++, even assigning a value to a variable is a statement. As well, expressions are the "number crunching" component of the language, and this is especially useful for game development. Any time a vehicle moves a velocity (v) over a time (t) it's going to travel some distance (x). Any time a person animates, or an object shows up in 3d space, or even in 2d space...we're using math. Expressions are how we do math in C++. Additionally, we will cover the 'if' statement in this chapter. Up until this point your exercises and programs have done exactly one "thing." The introduction of branching means your programs can now take different paths of execution. Beginning this week you will be given more "exercises" than before as it now possible to actually code something useful. This chapter is approximately 30 pages - not counting the summary, questions and exercises. Roughly half way through the week myself, tutors, or anyone else simply wishing to challenge their teammates learning C++ can post review and quiz questions in this thread. Please do not post the answers in this thread however, as a new thread will be created for that purpose. Outline of the Reading- Starting with Statements
- Expressions
- Working with Operators
- Combining Assignments and Mathematical Operators
- Incrementing and Decrementing
- Understanding Operator Precedence
- Nesting Parentheses
- The Nature of Truth
- The 'if' Statement
- Using Braces in Nested 'if' Statements
- Using the Logical Operators
- Short Circuit Evaluation
- Relational Precedence
- More about Truth and Falsehood
- The Conditional (Ternary) Operator