Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Meet with your team later today in ELL321 at 6:30pm. Teams are listed on the Project page of the course.

Similar presentations


Presentation on theme: "Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Meet with your team later today in ELL321 at 6:30pm. Teams are listed on the Project page of the course."— Presentation transcript:

1 Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Meet with your team later today in ELL321 at 6:30pm. Teams are listed on the Project page of the course web site. What to do is on the next slide. TAs are also prepared to help you with assignment questions, IDE problems, etc. later in the tutorial. Still need to provide you with a list of “incomplete” previous projects.

2 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? If Redmine is ready (not likely) notes can be recorded in the Wiki, otherwise keep separate notes on paper or on a laptop and copy them into the Wiki for when Redmine is available. Fall 2015CISC/CMPE320 - Prof. McLeod2

3 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” that will be sent to the CEO and put in your Wiki. Start thinking about two major roles that must be filled soon: Team Manager and Primary Software Architect. Fall 2015CISC/CMPE320 - Prof. McLeod3

4 Fall 2015CISC/CMPE320 - Prof. McLeod4 The Role of the Primary Software Architect Forms and owns the mental model of the software product. –Includes the detailed specifications for all functionality. Must communicate this model to the rest of the team. Prevents deviations from the model. Must represent the user when it comes time to form tradeoffs between time to completion, cost, performance and ease of use. Like a movie director!

5 Fall 2015CISC/CMPE320 - Prof. McLeod5 Primary Software Architect, Cont. Does not necessarily write any code (in the “real world”) – in this course he or she will have to! This job can be too demanding for one person on a very large project. So, it can be split up along very clear system boundaries. Object oriented programming languages help enable this splitting up. But all architects must agree on the overall vision.

6 Fall 2015CISC/CMPE320 - Prof. McLeod6 Architect – Builder Interaction The code writers or “Builders” implement the architect’s vision. The architect should not decide on how the functionality is implemented – he can only suggest. This allows the builders to come up with better ideas. In CISC/CMPE320 – all team members will be code writers.

7 Fall 2015CISC/CMPE320 - Prof. McLeod7 Project Management Role The primary architect will be too busy to fill a management role too. So another person should be the project manager. Like a movie producer. He is responsible for the implementation of the architect’s vision.

8 Fall 2015CISC/CMPE320 - Prof. McLeod8 Other Roles Chief Programmer Other Programmers, like component programmers and other specialist programmers Note-takers Archivists (Wiki maintenance) Technical Writers (Wiki content) Illustrators Testers Accountant Public relations Researcher Interface specialist Artists Story writers Repository design and maintenance …

9 Today C Strings Structs Operators Fall 2015CISC/CMPE320 - Prof. McLeod9

10 Last Time We found that arrays are not “policed” very well. It is easy to move beyond the bounds of the array without any error, other than getting garbage values. You are encouraged to use the vector class in a C++ program instead. Part of the STL. Fall 2015CISC/CMPE320 - Prof. McLeod10

11 Fall 2015CISC/CMPE320 - Prof. McLeod11 Arrays and Strings In C, you had to use char[] to store a string literal: char oldString[] = "Hello there!"; These “C-strings” end with the character '\0', also called the “null character”. Manipulating C-strings means manipulating arrays – generally a real pain… In C++ use the string class instead! Defined in the string library, and uses the std namespace. More about string s later…

12 Fall 2015CISC/CMPE320 - Prof. McLeod12 Structures A kind of class. Defined as an aggregate of other types. For example: struct address { string name; int streetNumber; string street; string city; string province; string postalCode; }; Note “;”

13 Fall 2015CISC/CMPE320 - Prof. McLeod13 Structures, Cont. See StructureDemo.cpp (Also note use of pointers with a function, and use of const in parameter list – getting a bit ahead of ourselves!!) Note how Eclipse gives you the membership list for an address.

14 Fall 2015CISC/CMPE320 - Prof. McLeod14 Member Selection Operators The example also demonstrated the use of the two member selection operators: The “dot operator”: object.member De-referencing and membership: pointer->member The latter is the same as: (*pointer).member (“Members” are attributes or methods (or member functions)…)

15 Structures, Cont. A struct is a primitive object definition with no privacy for it’s members. Why use them in C++? Fall 2015CISC/CMPE320 - Prof. McLeod15

16 Fall 2015CISC/CMPE320 - Prof. McLeod16 Operators Discussed in order of highest to lowest precedence. Highest Precedence: Scope resolution (when defining only): class_name::member Or namespace_name::member

17 Fall 2015CISC/CMPE320 - Prof. McLeod17 Operators, Cont. Next Highest Precedence (level 2): Member selection. (see slide 14). Subscripting arrays: pointer[expr] ( ) when used with function calls or value constructors. Post increment or post decrement: var++ var—- Type identification: typeid(type or expr) Casts like static_cast (expr)

18 Fall 2015CISC/CMPE320 - Prof. McLeod18 Aside – typeid() Used to find out the types of pointers. More useful in a function: A trivial example: int aVal = 100; int* ptr_aVal = &aVal; cout << typeid(ptr_aVal).name() << endl; Displays: Pi

19 Fall 2015CISC/CMPE320 - Prof. McLeod19 Operators, Cont. Level 3 Precedence: sizeof(type) Pre-increment and pre-decrement. Complement: ~expr Not: !expr Negation: -expr Address of and dereference ( & and * ) The heap operators: new, delete and delete[] C – style cast: (type)expr

20 Fall 2015CISC/CMPE320 - Prof. McLeod20 Operators, Cont. Level 4: Member selection (and dereference) -> Level 5: Multiply, Divide, Modulo: *, /, % Level 6: Add, subtract: +, -

21 Fall 2015CISC/CMPE320 - Prof. McLeod21 Operators, Cont. Level 7: Bitwise shift left: expr << expr Bitwise shift right: expr >> expr Level 8:, >= Level 9: ==, !=

22 Fall 2015CISC/CMPE320 - Prof. McLeod22 Operators, Cont. Levels 10 to 12: Bitwise AND: expr & expr Bitwise exclusive OR (or XOR): expr ^ expr Bitwise OR: expr | expr Levels 13 and 14: Logical AND: expr && expr Logical OR: expr || expr Level 15: Conditional Expression: expr ? expr : expr

23 Fall 2015CISC/CMPE320 - Prof. McLeod23 Operators, Cont. (Still!) Level 16: All assignment operators: = *=, /=, %=, +=, -=, >=, &=, |=, ^= Level 17: Throw exception: throw expr Lowest Precedence!: Comma:,

24 Fall 2015CISC/CMPE320 - Prof. McLeod24 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, an assignment operator can return something!)

25 Fall 2015CISC/CMPE320 - Prof. McLeod25 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.

26 Fall 2015CISC/CMPE320 - Prof. McLeod26 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 ^ : ABA&BA|BA^B 00000 01011 10011 11110

27 Fall 2015CISC/CMPE320 - Prof. McLeod27 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 2 n. Right shift, >>, moves all bits to the right. For unsigned integers zeros are added to the most significant bits – same as dividing by 2 n. For signed integers, the result is not predicable as the sign bit may be duplicated.

28 Fall 2015CISC/CMPE320 - Prof. McLeod28 Bitwise Operations, Examples Set the n th bit in a number and the rest are zeros: 1 << n To set the n th bit of any number, x, and not change the rest: x = x | 1 << n To check to see if the n th bit is set: if ((x & 1 << n) != 0)…


Download ppt "Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Meet with your team later today in ELL321 at 6:30pm. Teams are listed on the Project page of the course."

Similar presentations


Ads by Google