Skip to content
Permalink
Browse files
Add lecture examples
  • Loading branch information
David committed Dec 7, 2018
1 parent 0926e07 commit 0516c2f6dfd82438e3e8ce16c6b015728672f82c
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 6 deletions.
@@ -1,7 +1,14 @@
bin/
build/
.vscode/
CMakeFiles/
Temporary/
__pycache__/

solution_*
Solutions/*.cpp
Solutions/*.h
password

CMakeCache.txt
CMakeScripts
@@ -9,12 +9,8 @@ foreach(filename ${files})
# if lec file is "lec_thingy.cpp" then created test will be called "bin/lec_thingy"
get_filename_component(EXEC ${filename} NAME_WE)

# skip over the lec_error example as it won't compile
if(EXEC STREQUAL "lec_error")
continue()
endif()

# create the executable
add_executable(${EXEC} ${filename} ${HEADERS})
endforeach()

set_target_properties(lec_permissions PROPERTIES EXCLUDE_FROM_ALL true)
@@ -0,0 +1,36 @@
How did the programmer die in the shower?
He read the shampoo bottle instructions: Lather. Rinse. Repeat.

Eight bytes walk into a bar. The bartender asks, "Can I get you anything?"
"Yeah," reply the bytes. "Make us a double."

Two bytes meet. The first byte asks, “Are you ill?”
The second byte replies, “No, just feeling a bit off.”

How many programmers does it take to change a light bulb?
None – It’s a hardware problem.

Why do programmers always mix up Halloween and Christmas?
Because Oct 31 equals Dec 25.

There are only 10 kinds of people in this world.
Those who know binary and those who don’t.

Knock, knock.
Who’s there?
Very long pause….
Java.

Programming is like sex:
One mistake and you have to support it for the rest of your life.

A man is smoking a cigarette.
His friend becomes irritated "Can’t you see the warning on the cigarette pack?"
"Smoking is hazardous to your health!"
The man replies, "I'm a programmer".
"We don’t worry about warnings; we only worry about errors".

One hundred little bugs in the code
One hundred little bugs.
Fix a bug, compile the code,
Two hundred little bugs in the code.
@@ -0,0 +1,27 @@
#include <iostream>
using namespace std;

class MyClass
{
public:
int someVariable;

void some_function()
{
// do something
}
};

int main()
{
// creating an instance of the class
MyClass anInstance;

// using an attribute from the instance
anInstance.someVariable = 42;

// using a function from the instance
anInstance.some_function();

return 0;
}
@@ -0,0 +1,36 @@
#include <iostream>
using namespace std;

class MyClass
{
public:
int someVariable;

MyClass()
{
someVariable = 42;
}
};

class MyClassB
{
public:
int someVariable;
const float someConst;

MyClassB() : someConst(1.23f)
{
someVariable = 42;
}
};

int main()
{
// creating an instance of the class
MyClass anInstance;

// using an attribute from the instance
anInstance.someVariable = 42;

return 0;
}
@@ -0,0 +1,50 @@
#include <iostream>
using namespace std;

class MyClass
{
private:
int somePrivateVariable;

int some_private_method()
{
return somePrivateVariable;
}

public:
int somePublicVariable;

int some_public_method()
{
return somePrivateVariable;
}

MyClass()
{
/* constructor is a member of MyClass
so has access to private attributes */
somePublicVariable = 42;
somePrivateVariable = 69;

// and methods
some_private_method();
}
};

int main()
{
// creating an instance of the class
MyClass anInstance;

// can access public attributes/methods
anInstance.somePublicVariable = 99;
anInstance.some_public_method();

// no access to private outside of class
// WONT COMPILE
anInstance.somePrivateVariable = 99;
// WONT COMPILE
anInstance.some_private_method();

return 0;
}
@@ -0,0 +1,14 @@
#include <iostream>
using namespace std;

#include "lec_sep_concerns.h"

int main()
{
JokeStore js;
js.load( "Lecture/jokes.txt" );

cout << js.random() << endl;

return 0;
}

0 comments on commit 0516c2f

Please sign in to comment.