Index

SchoolNotes

  1. CS225
    1. Introduction
    2. Lesson 1
    3. Lesson 2
    4. Lesson 3
    5. Lesson 4
  2. CS251
    1. The Beginning
  3. CS180
    1. Introduction
    2. Midterm Revision
    3. Finals Revision
    4. CS251
    5. Memory
    6. ELF Format
    7. History of Computers
    8. Stuff to Research
    9. Quiz To-Do
    10. OS Architectures
    11. Week 3
    12. Week 4
    13. Week 5
    14. Week 6 (Threads)
    15. Week 7 (Scheduling)
    16. Week 8 (Thread Scheduling)
    17. Week 9 (Memory Management)

OLD SHIT

  1. CS225 (OLD ONE IGNORE THIS)
    1. OOP
      1. Inheritance
      2. R-Value References
    2. Misc Notes
    3. Size/Offsets of Structs/Classes
    4. Week 4
  2. CS200 (IGNORE THIS TOO)
    1. Introduction
    2. Scan Conversion
    3. Quiz 01
  3. GAM200 (YEAH, IGNORE THIS TOO)
    1. Notes

Week 4

AUTO

Auto is done via deduction.

template <typename T>
void foo(T haha);

int x[4][10]; //x is array of 4 arrays of 10 ints
auto y = x; //Type of y is deduced
auto p = &x; //p is a pointer to the int[4][10]
//p is a pointer to an array of 4 arrays of 10 ints.
// int (*p) [4][10];
foo(x) //What is the type of foo(x)?

/*
x is an array of 4 arrays of 10 integers.

Let u be an array of T.
T u[10];
u is an array of 10 T objects.
foo(u);

- Cannot pass arrays directly to other functions
- Pass the pointer to the first element over to foo.
- The type of argument for foo is deduced to be T *

What if T itself is an array?
int p[20][30];
- How many elements does p have? 20.
- p is an array of 20 (arrays of 30 ints). The stuff in the bracket is the element type of the array! 
- When p is passed into a function, the argument to the first element is passed.
- Argument to the first element is a pointer to the array of 30 ints.
- Possible to write that in C/C++?
   → int [30] * s; //Of course does not work - array have to be on the right.
   → int *s[30]; //Again, this won't work for obvious reasons (right-left)
   → int (*s) [30] //WORKS
*/


//void foo(int (*g)[]);

//GG is an array of 10 pointers to an array of 20 function pointers to functions that takes in a double, a short and returns a pointer to array of 10 floats.

float (* (*(*GG [10]) [20]) (double,short)) [10];

//If it returns an array instead of pointer to array, NC.

//No functions of functions, no functions of arrays, no arrays of functions
//pointers to arrays of unspecified sizes is ok surprisingly


The only thing you can pass over to a function that is bigger than 8 bytes is a struct/class in C/C++.