C++ Primer Notes

A function consists of four parts: a return type, the function name, a parameter list, and the function body. The first three parts are collectively referred to as the function prototype.

return, a predefined C ++ statement, provides a method of terminating the execution of a function.

#include is a preprocessor directive

Preprocessor directives are specified by placing a # sign

#include <some_file.h> // the file is presumed to be a project or standard header file.

#include "my_file.h"// the file is presumed to be a suer-supplied header file.

iostream is the iostream library standard header file

 

using namespace std; //this is called using directive~ The names in the C++ standard library are declared in a namespce called namespace std. The using directive tells the compiler to use the library names declared in namespace std.

Programming Methodology--CS106A Comments(6) Fri, 02 Mar 2012 15:48:30 -0700

Stanford opencourse--CS106A--Programming Methodology--notes

cs106a.stanford.edu

 

Lec1

knowing the language doesn't make you a good programmer. Focusing on the software engineering concepts is very important. 

 

Karel the Robot

 

Problem solving is the essence of programming.

Object-oriented programming: the programmer’s attention shifts away from the procedural specification of operations and focuses instead on modeling the behavior of conceptually integrated units called objects.

 

class is a pattern or template for objects that share a common behavior and collection of state attributes.

 

Whenever you have an actual robot in the world, that robot is an object that represents a specific instance of the Karel class

 

Lec 2

Karel's language (methods):

move

turnLeft

pickBeeper

putBeeper

methods--some instructions that we can call

 

public class FirstKarelProgram extends Karel

public void run() {

 

}

run is a method for Keral

 

while loop: do something while there's some condition that's true

Programming Methodology--CS106A Comments(9) Wed, 01 Feb 2012 15:41:34 -0700