nuoxoxo / cpp_modules_42

My solutions to CPP Pool @ 42 - [ Module 9 Added ]
0 stars 0 forks source link

cc6 - Casts - EVAL #104

Open nuoxoxo opened 1 year ago

nuoxoxo commented 1 year ago

ex00 - $\color {Orange} \text {EVAL} $

static uintptrt serialize(Data * ) { return (reinterpret_cast(_)); }


- ___- Is the struct Useful ?? -___ 
  - of course
    - see _main_
# ex02 - $\color {Orange} \text {EVAL} $ 
- `void identify (Base *p)` should check if _dynamic_cast<>_ returns 0/NULL
  - ❗ on failure 
   - <kbd> dynamic_cast<_new_type_>(*) </kbd> return a NULL point of _new_type_ 
- `void identify (Base & p)` should check with `try...catch`
  - ❓ why `try...catch`
  - BECAUSE you can have a null pointer, but not a null reference - any reference has to be bound to an object.
  - SO when <kbd>dynamic_cast</kbd> for a pointer type fails it returns a null pointer which we can check
  - BUT when it fails for a reference type, it cannott return a ___null reference___, so an 
- ___-  "header must not appear anywhere" -___ 
  - No idea what it means.