Download presentation
Presentation is loading. Please wait.
1
CISC/CMPE320 - Prof. McLeod
Winter 2013 CISC/CMPE320 2/4/2019 CISC/CMPE320 Teams are assembled. They are listed on the project page. Make sure you are listed! Let me know if you are with someone that you cannot get along with (bloodshed might result…). Also, let me know of any spelling errors. And, if you are going to drop the course, do it soon, svp… Jira account creation is in progress. You will get an that expires in 24 hours to login. Fall 2018 CISC/CMPE320 - Prof. McLeod Prof. Alan McLeod
2
CISC/CMPE320 - Prof. McLeod
Today First team meeting today. Deliverables. C++: Finish Operator Precedence Bitwise Operations Boolean Expressions Conditionals and Loops string and vector classes from the STL: demos Fall 2018 CISC/CMPE320 - Prof. McLeod
3
Review - First Team Meeting
Introduce each other - Exchange contact info? Present your background/experience. Which hardware/OS do you like to use for C++ development? Has each member read over and understood the projects page? Do you know what the deliverables are and when they are due? Pick a notetaker for this meeting. Notetaker takes attendance and records any momentous decisions – is anyone missing? Use Confluence to record notes and link them to an issue in Jira. Or, keep separate notes on paper or on a laptop and copy them into Confluence later. Fall 2018 CISC/CMPE320 - Prof. McLeod
4
First Team Meeting, Cont.
Discuss project ideas – negotiate? Other meeting time(s) than just the tutorial time? If you do settle on a project idea, discuss it with your TA (your mentor) to see if it is too hard/too easy and just what might be involved with implementation. Write an “executive summary” to be sent to the CEO. Start thinking about two major roles that must be filled soon: Team Manager (or “Lead”) and Primary Software Architect. Start putting in your story line so you can build your first sprint! Fall 2018 CISC/CMPE320 - Prof. McLeod
5
Immediate Deliverables
This week or next week, at the latest: Report a membership “deficiency” to your mentor or to the CEO. Choose a project topic. Choose a manager (or team lead). Optional: Choose an chief architect. the CEO with the name of the manager. Provide the CEO with an “executive summary” of your project concept by . Add meeting notes (including attendance) to your team’s Confluence space. Fall 2018 CISC/CMPE320 - Prof. McLeod
6
CISC/CMPE320 - Prof. McLeod
Notes on Precedence Prefix operators (~, !, -, &, *, pre-increment and pre-decrement) and assignment operators are right associative (right to left) – all others are left-associative (left to right). So: int a = b + c + d; Means int a = (b + c) + d; But, int x = y = z; Means int x = (y = z); (Yes, the assignment operator returns something!) Fall 2018 CISC/CMPE320 - Prof. McLeod
7
CISC/CMPE320 - Prof. McLeod
Precedence Notes, Cont. Use ( ) to control precedence. When in doubt, control precedence! If an expression gets too long, use intermediate variables to make it more readable. Fall 2018 CISC/CMPE320 - Prof. McLeod
8
Bit and Shift Operations
These operate on all integer types and enums. Complement, ~, carries out a bitwise negation of each bit (1 becomes 0, 0 becomes 1). Binary &, | and ^: A B A&B A|B A^B 1 Fall 2018 CISC/CMPE320 - Prof. McLeod
9
Bit and Shift Operations, Cont.
The left shift operator, <<, moves all bits in val to the left by n positions: val << n. Zeros are added to the least significant bits. This is the same as multiplying a number by 2n. Right shift, >>, moves all bits to the right. For unsigned integers zeros are added to the most significant bits – same as dividing by 2n. For signed integers, the result is not predicable as the sign bit may be duplicated. Fall 2018 CISC/CMPE320 - Prof. McLeod
10
Bitwise Operations, Examples
Set the nth bit in a number and the rest are zeros: 1 << n To set the nth bit of any number, x, and not change the rest: x = x | 1 << n To check to see if the nth bit is set: if ((x & 1 << n) != 0)… Fall 2018 CISC/CMPE320 - Prof. McLeod
11
CISC/CMPE320 - Prof. McLeod
Boolean Expressions We have seen the boolean operators already. Here are a few notes: Something like a < b < c will compile and run, but may not produce the desired result. Better to use: a < b && b < c Remember that & and | are bitwise operators, not logical ones. Fall 2018 CISC/CMPE320 - Prof. McLeod
12
Boolean Expressions, Cont.
The && and || logical operators use “short circuit evaluation”: For && if the LHS is false then the RHS is not evaluated. For || if the LHS is true then the RHS is not evaluated. (Same as in Java.) Fall 2018 CISC/CMPE320 - Prof. McLeod
13
Boolean Expressions, Cont.
Non zero integers are treated as being true, and zero is treated as being false. (Ouch!) So, you can use logical operators, && || and !, with integers. For example, the code: int x = 10; if (x) is the same as: if (x != 0) Fall 2018 CISC/CMPE320 - Prof. McLeod
14
Boolean Expressions, Cont.
Also, this is legal syntax: if (x = 10) The assignment operator returns the value being assigned, which in this case is a true! But suppose x is 12 and you really meant to type ==… Ouch, again! Fall 2018 CISC/CMPE320 - Prof. McLeod
15
Boolean Expressions, Cont.
See TestStuff.cpp. Applying ! to a non-zero integer returns false or zero. An if statement will treat a pointer by itself as an integer – it will be true unless it is nullptr. You can also test assignment statements since the assignment operator returns the value being assigned. Fall 2018 CISC/CMPE320 - Prof. McLeod
16
Conditional Expressions
C++ has if, if/else and switch. Syntax of if/else: if (boolean_expression) true_part else false_part Use { } to enclose more than one statement. Fall 2018 CISC/CMPE320 - Prof. McLeod
17
CISC/CMPE320 - Prof. McLeod
switch Statement Same syntax as in Java: switch (expression) { case val1: // statements if expression produces val1 break; case val2: // statements if expression produces val2 case val3: … default: // statements if none of the above is true } // end switch Fall 2018 CISC/CMPE320 - Prof. McLeod
18
CISC/CMPE320 - Prof. McLeod
switch Statement, Cont. expression must be an integer. The break statements are needed to prevent the next case statement from taking place if the one above it is true. The default is only executed if none of the other case blocks have executed. Fall 2018 CISC/CMPE320 - Prof. McLeod
19
The Conditional Operator
int max = (n1 > n2) ? n1 : n2; Is the same as: int max; if (n1 > n2) max = n1 else max = n2 Which is easier to read? Fall 2018 CISC/CMPE320 - Prof. McLeod
20
CISC/CMPE320 - Prof. McLeod
Loops Three types: while (condition) statement_or_block do while(condition); for(init; condition; expr) Fall 2018 CISC/CMPE320 - Prof. McLeod
21
CISC/CMPE320 - Prof. McLeod
Goto C++ also has the infamous “goto” statement: goto identifier : …. identifier : statement Don’t use it! (Maybe use it to kick you completely out of a nested loop. break only kicks you out one level…) Fall 2018 CISC/CMPE320 - Prof. McLeod
22
CISC/CMPE320 - Prof. McLeod
break and continue Work as they do in Java: break; spits you right out of the loop. continue; sends you back to the loop condition. Fall 2018 CISC/CMPE320 - Prof. McLeod
23
CISC/CMPE320 - Prof. McLeod
As Promised Demos of the string and vector classes: StringDemo.cpp VectorDemo.cpp Much better than C-strings and arrays! Fall 2018 CISC/CMPE320 - Prof. McLeod
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.