1) You use it to access a class-definition or namespace. You cannot use it on an instantiated object.
2) A static object that resides within the global namespace with file-scope. It resides within a specially allocated region of memory. The identifier can be shadowed.
3) I don't understand what you mean. An example?
4) The condition is evaluated last in both expressions because relational operators have a lower precedence than the arithmetic operators.
5) You can't do this. Identifiers must not begin with a number.
6)
b will be initialised to the value that's already at the location when the variable was made. Usually, this value is completely random. Adding
b (uninitialised) to
x (uninitialised) could well cause a range overflow, meaning that the assigned value is too large for the specified type.
7) It will increment
myInt but will test the old value. Before the body is executed,
myInt's value would've changed.
8) I'm not too sure what you mean here. When you say
"but not specify the variable TYPE", are you referring to the variable's type, or the initial data's type?
9) Only after the closing brace of a class and an array's initialiser list.
10) The compiler will probably produce an error due to ambiguity, or it may use the Boolean declaration (because almost every data-type is convertible to a Boolean type).
11) Yes you can, but it doesn't make a difference. However, there's none for
string (because it's a class), or
float.
12) Use the ternary operator:
|
int Bigger((1 > 2) ? 1 : 2);
| |
13) Not too sure what you mean here.
14) Only if
std::string is inherited from. However,
std::string lacks a virtual destructor.
std::string::c_str() returns a c-string equivalent to the string currently stored in the
std::string object. And, yes, you could do that.
15) No, there's no such thing. Even if there was, the compiler will probably optimise it away if it isn't used.
16) No. A string is of type
const char *. You'd be assigning the address of the first character of the string to the
int. Even that assignment is an error because an address is actually a pointer, unless you wrote:
0x...., which is an
int.
17) A sequence of characters. A
std::string is a class that encapsulates a
char *; typically stored in RAM. A
const char * is a pointer to a constant sequence of characters; typically stored in ROM.
18) Can you expand on this?
19) A statement is typically an instruction. Statements are identified by the semi-colon the follows it. Statements are things like:
- Function calls
-
throws
- Object & class declarations
- assignment
...and so on. Note that expressions are not statements, but part of statements.
20) Yes, both
tempPass and
realPass will both be declared as
unsigned short int.
Wazzak