Introduction and a Review of Basic Concepts Syllabus

Introduction and a Review of Basic Concepts • Syllabus and goals of the course • Object oriented programming contrasting to C programming – Objects, classes, methods – Instantiation, references – Polymorphism, inheritance – Constructor, destructor, garbage collection – Encapsulation – Public, private, protected • Data structures already introduced: Stacks, queues, linked lists • Recursion and induction Understanding data structures and algorithms is a major difference separating computer scientists from one who reads a manual and begins to program.

C versus Java • The dot in Java is equivalent to the -> C; there is no Java equivalent to the C dot operator. Generally, use -> in most cases and declare variables using the ‘*’ (indicating pointer) • There is no Boolean in C. Many programmers declare TRUE and FALSE using #define • C has no garbage collection. To avoid memory leaks, make sure to free whatever you malloc. • Use NULL in C, instead of the null in Java • Use scanf for input, but make sure to clear the input buffer after an error (scanf("%s*")) • C has no methods (it has functions), so dot notation makes no sense. Replace: object. method by function(data • There is no length property in arrays and strings. Array sizes must be stored in a separate variable. • Be careful with pointers and memory management. C doesn’t catch all errors at compile time.

Strings in C • There is no String type, use an array of characters (char *data). • C has no “+” operator for string concatenation. Use strcat, but make sure you have an allocated area in memory to hold the larger string. • To truncate a string, store '