Lab 2
Topics: C++ Classes, member functions, constr, destr, CC, AO, interface vs. implementation
Getting started:
- point browser to https://skatgame.net/mburo/courses/350
- click on B2 in the schedule
- use id/pw listed on eclass to get access if asked
- this should bring up this page
Part 1 (14:00)
Part 2 (~14:10)
- Prep problems (see below)
Part 3 (15:20)
Part 4 (15:30)
Prep Problem 1:
Paste the following code into file e1.cpp and implement Bar's constructor,
destructor, CC, and AO in e1.cpp. Also define function main() that invokes
Bar's constructor, destructor, CC, and AO
struct Foo
{
// details immaterial
};
struct Bar
{
Foo x;
Foo *p; // always pointing to 10 solely owned Foos
};
Test your program and make sure it doesn't leak memory (using valgrind)
Your project must compile with g++ -Wall -Wextra -O -g -std=c++17 e1.cpp
Prep Problem 2:
For classes Foo, Bar used in problem 1, create individual interface (.h) and
implementation (.cpp) files Foo.h, Bar.h, Bar.cpp. For this problem, interface
files must not contain ANY method implementations. Also create file main.cpp
that defines function main() which allocates 10 Bar objects on the heap and
then frees them
Test your program and make sure it doesn't leak memory (using valgrind)
Your project must compile with g++ -Wall -Wextra -O -g -std=c++17 Bar.cpp main.cpp
Prep Solutions (link will be shared in time)
Lab Exercise (link will be shared in time)
Secrets (link will be shared in time)