Question: Please answer in C++ Coding Language! What am I doing wrong? Could someone explain? The problem: Here is Foo.h: Here is Foo.cpp: Here is main.cpp:
Please answer in C++ Coding Language! What am I doing wrong? Could someone explain?
The problem:

Here is Foo.h:

Here is Foo.cpp:

Here is main.cpp:

Here is my code in Bar.h:

Here is my code in Bar.cpp:

I dont think what I'm doing is correct at all but I also don't know how to access Foo's private name_ variable inside Bar class. Please provide updated code if possible
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. 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 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 foo's in the world. \#pragma once \#include namespace potd \{ class foo \{ public: Foo(std: :string); Foo(const Foo \&); Foo \& operator=(const Foo \&); rFoo(); static int get_count(); std::string get_name(); private: static int count_; std::string name_; 3)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
