Lecture overview -- Keyboard shortcut: 'u'  Previous page: Control structures -- Keyboard shortcut: 'p'  Next page: Call-by-reference parameters via pointers -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 1 - Page 22 : 29
Notes about C++
From C to C++
Functions and parameters

Non-nestable functions

Parameters are value parameters - Call-by-value

  • Function basics

    • Named, statically typed

    • Void (returns nothing) or with a single return type

    • Functions cannot be nested in each other in ANSI C - C89

      • A non-standard gcc extension allows such nesting, however.

  • Parameters

    • Parameters are passed by value

      • Pointers passed as value parameter: "Call-by-reference"

    • Positional correspondence

    • There exists an "ugly" variable length parameter mechanism

      • Unspecified number of arguments: int printf(const char* ...)

  • From C to C++

    • Overloaded functions: Several functions with the same name

    • Default arguments: Trailing parameters can be given default values in the formal parameter list

    • int f() in C++ corresponds to int f(void) in C

    • Lambda expressions in C++11