Guide

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 2

DownloadGuide
Open PDF In BrowserView PDF
POTD7.1. Problem of the Day #7

Download and Extract
An initial setup of files is provided to you via a shell script: Download potd-q7
Using a terminal, extract the initial files by running the shell script you just downloaded (you
will need to navigate to the directory where you saved the file):
sh potd-q7.sh

Your files for this problem will be in the potd-q7 directory.

POTD 7
Total points:
Score:

0%

Question
Value:

1

History:
Awarded points:

The Problem
Today you will become one with the Rule of Three. You are given a class Foo that takes a
name for its constructor. The Foo has a get_name() method that returns the name of the Foo.
The Foo class also keeps track of how many Foo's exist using something called a class
variable, but that is not something we have gone over in class yet.

0/1

0/1

Report an error in this question

Previous question
Next question

Your work is to create a Bar class that also has a name, but it stores its name by creating a
new Foo. You will put your code in Bar.h and Bar.cpp. This class should reside in the potd
namespace.
TODO: The class Bar, including:
A private member variable Foo * f_.
A constructor that takes a string.
A copy constructor.
A destructor.
An operator=.
A method string get_name() to return the name contained within f_.
Be sure to allocate your memory correctly!

Testing Your Code
This time we give you a main.cpp. Run the following commands to compile and execute your
code:
make
./main

Sample Output

There are 0 Foo's in the world.
There are 1 Foo's in the world.
There are 2 Foo's in the world.
There are 3 Foo's in the world.
b1 is aramis
b2 is aramis
b3 is porthos
There are 3 Foo's in the world.
b1 is porthos
b2 is porthos
b3 is porthos
There are 2 Foo's in the world.
There are 1 Foo's in the world.
There are 0 Foo's in the world.

Upload Solution
Drop files here or click to upload.
Only the files listed below will be accepted—others will be ignored.

Save & Grade
Files
Bar.h
not uploaded

Bar.cpp
not uploaded

Save only



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
Linearized                      : No
Page Count                      : 2
PDF Version                     : 1.4
Title                           : PrairieLearn
Author                          : DYT
Subject                         : 
Producer                        : Mac OS X 10.12.6 Quartz PDFContext
Creator                         : Safari
Create Date                     : 2019:02:01 05:57:59Z
Modify Date                     : 2019:02:01 05:57:59Z
Apple Keywords                  : 
EXIF Metadata provided by EXIF.tools

Navigation menu