cs Sept 16, 2014
const : some values may not be known at run time cant change the value after being given initial values.
void use (int n)
{
const int c2 = n + 7; // cant change after being set but can be set during run time
}
constexpr" all the vales are known at compile time and cant change during runtime.
constexpr double pi = 3.14;
Both static memory allocation.
Chapter 4:
Review
5. compare and contrast expression and statement..
A statement is an expression followed by a semicolon..
4. An expression evaluates something or computation..
2. inputs to an computation cout << x . in this case cout and x.
ouputs of computation: cout<<x is cout object...
Final exam : What is the declaration of this function : cout <<x; or operator<<(cout, x);
ostream & operator<<(ostream &, int);
might ask the definition of this function as well.
^. lvalue
a + b
a = b // a must be a lvalue..
lvalue (variable) are modifed. rvalue are the not modified values..
How many ways an lvalue can be modified ?
1.assignment and cin >> x (input value)
2.assignment statement
3.for (auto x: a)
x changes to each element ..
a is a collection vector array.
How do you avoid unnamed constant.. use symbolic constant.. constexpr double pi = 3.14;
18. cout << ch;
print numeric value of a character..
cout <<(int) ch;
cout<<static_cest<int> (ch);
19. char foo(int x); //declaration of function takes an integer and returns a char..
20. 1. modular, readable.repeatable

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home