Changes

Jump to: navigation, search

Week 5

1,040 bytes added, 15:14, 10 June 2010
no edit summary
In C, everything upcasts. (so if you have an expression, it will upcast all the variables to the largest type).
 
'''<u>New Concepts</u>'''
 
Page 36 - review it carefully.
 
difference between a structure and a class in C++ structure is public by default, classes are private by default.
 
in c - instantiate a structure: struct student s;
c++ - student s;
 
union - places all the variables in the same place in memory.
enum weekdays(sun, mon, tue, wed, thu, fri, sat) - will create 7 constant ints starting from 0
 
typedef int age - adds the name "age" as an integer to the C library. so now u can say "age a = 34;" - same as saying int a = 34
 
c = 20 || 50
 
c = true because both 20 and 50 are not 0 which is false.
 
in the ? : operator both values must be same data type.
ignore page 37
 
bitwise operators??
AC 1010 1100 = A
4E 0100 1110 = B
 
A && B = 0000 0001
A & B = 0000 1100
A | B = 1110 1110
! A = 0000 0000
~A = 0101 0011
A^B = 1110 0010
 
A << 1 = 0101 1000 // left shift
B << 2 = 0011 1000
 
right shift - signed && left bit 1 if both these conditions are true, then fill the left with 1's otherwise 0's
 
B >> 3 = 0000 1001
A >> 2 = 1110 1011
1
edit

Navigation menu