Qualifiers
CV Qualifiers
const -- makes program throw an error if reassignment is attempted
mutable
volatile
Storage Duration Qualifiers
static -- lets a variable persist outside of the block in which it was defined
register
extern
This is kind of like my personal-notebook-in-the-cloud project as I learn to code. Follow along with my journey to becoming a better dev. Java, Android SDK, HTML and CSS, PHP, JavaScript, Jquery, Ruby, Python, Arduino, C++ and more.
CV Qualifiers
const -- makes program throw an error if reassignment is attempted
mutable
volatile
Storage Duration Qualifiers
static -- lets a variable persist outside of the block in which it was defined
register
extern
Notes based on Module 2 of Bill Weinman's LinkedIn course.
int * ip = &x //designates ip as a pointer (ip = int pointer), and gets memory address of x and stores it to ip
int & y = x //Makes y a reference to x (?)
const int & y = x //Prevents changing x's value by changing y's value
"receding the pointer" = changing what it points at
A REFERENCE cannot be redefined to refer to a different variable.
Size is set upon initialization and can't be changed thereafter
int array[] = {1,2,3,4,5};
int x = array[2];
//x will now return 3
Primitive string or c-string = a special (null-terminated) array of characters
char my_string[] = {'a', 'b', 'c', 0};
Which statement would correctly declare a variable s1 for the structure S declared in the following code?
struct S {
int i;
const char * s;
};
Answer: S s1 = { 3, "string one" };
Struct members default to public access.
example:
void no_return(int i)
{
puts(i);
}
Class members default to private access
A REFERENCE cannot be redefined to refer to a different variable.
A c-string is an array of characters
Use break to exit out of a switch
Any amount of whitespace is equivalent.
Semicolons must be used to terminate statements.
An expression is anything that returns a value.
Pointers are type-aware
What is one advantage of using cout instead of printf or puts?
>> The cout class is type aware, and can string together different data types.
Disadvantage:
The `cout` class tends to create LARGER executable files, which is one of its disadvantages.
The cout class is found in the iostream header
What are the necessary parts of a C for loop?
>> an expression, a condition, and post-loop control
What is a primitive string in C++?
>> Primitive strings in C++ are arrays that end in 0, so they can be iterated through like other arrays.
The for loop uses three expressions to control flow.
When using a range-based for loop with a c-string you must test for the null terminator.
The "main" function is the entry point of the program, called by the OS when the program launches
While struct members default to public access, class members default to private.
Initialized arrays have values defined in the array, and uninitialized arrays do not have values defined.
Basically it's a way to map a combined/minified file back to an unbuilt state.
Right now source mapping is only working between uncompressed/combined JavaScript to compressed/uncombined JavaScript, but the future is looking bright with talks of compiled-to-JavaScript languages such as CoffeeScript and even the possibility of adding support for CSS preprocessors like SASS or LESS.
In the future we could easily use almost any language as though it were supported natively in the browser with source maps:
- CoffeeScript
- ECMAScript 6 and beyond
- SASS/LESS and others
- Pretty much any language that compiles to JavaScript