Please send questions to st10@humboldt.edu .

*   so -- another kind of compound expression in C++
    ...function calls!

*   happily, these are LOT like a Racket function call:
    2 differences:

    Racket:   (sqrt 2)
    in C++, you put the opening parenthesis AFTER the function
    name:
    C++       sqrt(2)

    Racket:   (max 3 5)
    in C++, you SEPARATE argument expressions with a comma:
    C++:      max(3, 5)

*   Now, expressions in Racket were our main "top level"
    way of saying things;

    in C++, expressions tend to not be "top level" --
    instead, they make up parts of STATEMENTS,
    which often (but not always) tend to have side-effects;

    In C++, an expression in general tends to be like
       a phrase in a natural language sentence,
    while a statement in general tends to be like
       a complete sentence;

*   There is some important syntax related to statements
    in C++ --

    they are typically TERMINATED (ended) with	
    a semicolon!

    ...although a BLOCK --- which is 
    {
        statement;
	statement;
        ...
    }
    ...DOESN't usually end with a semicolon;
    and it is considered a single statement;

    (and you will be expected to indent
    it as shown above -- but more on that
    later...)

*   here's an example of a kind of C++ statement:
    the return statement

    *   the syntax:

    return <expr>;

    *   the semantics:

     stop the function this is in at this point,
     and make the value of the function the value of
     this <expr>

*   so, while in Racket the value of a function was
    the value of the expression in its body,
    in C++ the value of a function is the value
    of the expression in its return statement...

C++ IDENTIFIERS

identifier: a name the programmer chooses

C++ syntax for identifiers is stricter than in Racket:
they generally must start with a letter:
and are followed by 0 or more letters, digits, or underscores
*   so, NOTE -- dashes CAN'T be in C++ identifiers!
    (nor can ? or / or + or * etc.!)

*   and NO spaces inside of a name...!

*   and case still matters

*   style is the same -- make 'em MEANINGFUL!!
    (and named constants will also be in all-uppercase
    in C++..)

NOW -- we're ready for NAMED CONSTANTS in C++
you need a declaration STATEMENT for this;

*  like in Racket, you need to tell the computer
   that hey, here is a name, and I want it to
   have this value;

   ...but C++ is strongly typed, so I also tell
   it the TYPE of value that can be in that name;

   AND, C++ lets you say, this IS constant, don't 
   let it be changed...

*  HERE's the syntax:

   in Racket: (define SALUTATION "Greetings!")
              (define WIDTH 300)
   in C++:    const string SALUTATION = "Greetings!";
              const int WIDTH = 300;

   here's the basic syntax:
   const <type> <IDENTIFIER> = <expr>;

COMMENTS

*   in Racket, you put
 ; this is a comment

*   in C++, you have two kinds of comments:

    // single-line comment

    everything from // to the end of the line is ignored

    /* everything from here
       until the comment-closing characters
       is a multi-line 
       comment
    */

    everything between /* and */ is ignored

C++ function HEADERS

*   in Racket, a function header says that hey,
    we're defining a new function, here's its name,
    and here are the names of its parameters

*   in C++, a function header says that hey,
    we're defining a new function, here's its name,
    here's the TYPE of value this function returns,
    here are the names AND TYPES of its parameters


Racket:   (define (circ-area radius)
C++:      double circ_area(double radius)

Racket:   (define (ring-area outer inner)
C++:      double ring_area(double outer, double inner)

    So, C++ basic function header syntax
    <return_type> <funct_name>(<param_type> <param_name>,
                               <param_type> <param_name>,
                               ...
                               <param_type> <param_name>)

C++ function body:

*   put a block after the function header
    containing the statements for that function;
    IF the function is to produce a value,
    at least one of those statements had better
    be a return statement!

<function header>
{
   <statement>;
   ...
   return <expr>;
}

COURSE STYLE: the { for the function body is expected
   to be on the line after the function header,
   lined up with the beginning of the function header

   and, the statements within are indented by at 
   LEAST 3 spaces, (more is fine),
   and the } closing is lined up with the opening {

now: playing with funct_play2, a tool to
play with C++ functions BEFORE writing our own main
functions...

(see the screen shots of using funct_play2 to create
a circ_area function...)