Presentation is loading. Please wait.

Presentation is loading. Please wait.

Functions and More. Homework 1 Due September 11:59pm return a string count characters in a string call functions in a function.

Similar presentations


Presentation on theme: "Functions and More. Homework 1 Due September 11:59pm return a string count characters in a string call functions in a function."— Presentation transcript:

1 Functions and More

2 Homework 1 Due September 11 @ 11:59pm return a string count characters in a string call functions in a function

3 git Version control Might cover this in more detail later in the semester For now – git clone https://hartloff@bitbucket.org/hartloff/cse250- fall2015.git If SSH keys are needed (timberlake) – upload private key upload – git clone git@bitbucket.org:hartloff/cse250- fall2015.git

4 clone alternative Download files from the BitBucket web interface – Might get you through this course – Not ideal If you want to write software, you will need to learn version control at some point

5 ftp (file transfer protocol) To move files across machines If you want to develop locally – Use this to move your files to timberlake – submit_cse250 hw1.cpp Need ftp software – FileZilla FileZilla – sftp://timberlake.cse.buffalo.edu – Port 22

6 On to C++

7 Functions in C++ Function declaration – float foo(int); – C++ functions must be declared before they are called Function definition – float foo(int i){return i*1.5;} – can be defined later Put all declarations at the beginning of your file Header file – Go one step further and put declarations in a separate file – #include “stringFunctions.h”

8 Makefile Useful when a project contains multiple files A way to compile all necessary files with one command – make Blank space matters in Makefiles All Makefiles will be provided for you in this class

9 References & An alias (nickname) to a variable – int k = 3; – int& p = k; – p = 6; After executing these 3 lines – k == 6 – Both k and p refer to the same location in memory Why not assign 6 to k directly? – When you have access to p, but not k

10 back to functions void square(int i){i = i*i;} int r = 5; square(r); r == 5 When square is called int i = r; i = i*i;

11 back to functions & void square(int& i){i = i*i;} int r = 5; square(r); r == 25 When square is called int& i = r; i = i*i; Use references when a function should alter a parameter Caution: Be aware if a function takes a reference or not


Download ppt "Functions and More. Homework 1 Due September 11:59pm return a string count characters in a string call functions in a function."

Similar presentations


Ads by Google