-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.mdpp
53 lines (39 loc) · 2.73 KB
/
notes.mdpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
### Notes
This section contains interesting notes or ways I solved some intermed. problem
that I need to take a look at proabably later in time
- change mouse speed via xinput --list-props --set-prop
- ps -ejh for process tree, -aux for all
- snipmate for touching new, filled file containing snippets, make :SnipMateOpen tab and edit and save
- lvalue := locator value (represetns an object that opccupies some identifiable location in memory)
- rvalue
- of course it is possible to return a lvalue from a function (but ugly).
- lvalues remain lvalues even if they are const. const lvalues are not assignable. The lvalues that can be changed are called `modifiable lvalues`
- language constructs operatinng on object values require rvalues as arguments.
- all lvalues that are not arrays / functions / incomplete types canbe converted to rvalues
- basically * creates a lvalue from an rvalue
- & creates a rvalue from a lvalue
- otherwise defines reference types (lvalue references)
- NOTE: constant lvaue refernece can be assigned rvalues (as there is no fear that the rvalue will actually change)
- CV-unqualified / CV-qualifier: const and volatile qualifier
```c++
int* p = &arr[0];
*(p + 1) = 10; // OK: p + 1 is an rvalue, but *(p + 1) is an lvalue
```
-
# Heap and free store
In Herb's book "Exceptional C++", he defines:
Heap: A dynamic memory area that is allocated/freed by the malloc/free functions.
Free Store: A dynamic memory area that is allocated/freed by new/delete.
Its possible for new and delete to be implemented in terms of malloc and free, so technically, they could be the same memory area. However, as the standard doesn't specify this, its best to treat them separatly, and not to mix malloc/delete or new/free.
- http://zamanbakshifirst.blogspot.com/search/label/heap (bjarne stroustrup
- `I consistently use "free store" and "heap" is not a defined term in the C++ standard (outside the heap standard library algorithms, which are unrelated to new and malloc()). In relation to new, "heap" is simply a word someone uses (typically as a synonym to "free store") - usually because they come from a different language background`
# On default destructors / constructors
## What is the difference between virtual ~Class() {} or virtual ~Class = #default
### = default;
- considered not user-defined
- constructor: in case of value initialization for the constructor A* a = new A();
a special kind of initialization that does not use a constructor at all will take place.
`Zero-Initialization`.
- destrucuto: if a base / member with inaccessible / deleted destructor, it will only compile if
default destructor is selected and not if empty one is. However it will raise an exception
when the class actually is removed.