Question: C + + Please show full code and explanation. Step 1 : Producing correct output Three commented - out lines of code exist in main
CPlease show full code and explanation. Step : Producing correct output
Three commentedout lines of code exist in main Uncomment the lines and click the "Run program" button. Verify that the program's
output is:
Unknown function: PrintPlus
secret string: "abc"
Submit your code for grading. Your submission will pass the "Compare output" test only, achieving of the possible points.
Step : Inspecting the LabPrinter class
Inspect the LabPrinter class implemented in the LabPrinter.h file. Access LabPrinter.h by clicking on the orange arrow next to main.cpp at the top of the coding window. Member functions PrintPlus and Printsecret print strings using std: : cout.
Step : Implementing CallFunctionNamed
Remove the three uncommented lines from main Then implement the CallFunctionNamed function in main.cpp to handle three
cases:
If functionName is "PrintPlus call printer's PrintPlus member function.
If functionName is "PrintSecret", call printer's Printsecret member function.
If functionName is anything other than the two strings mentioned above, print "Unknown function: xyz where xyz is
functionName's value.
After implementing CallFunctionNamed click the "Run program" button. Verify that the program's output is once again:
Unknown function: PrintPlus
secret string: "abc"
Step : Submitting code for points
main.cpp
#include
#include
#include "LabPrinter.h
using namespace std;
void CallFunctionNamedLabPrinter& printer, string functionName
Only implement this function after completing step
int main int argc, char argv
LabPrinter printerabc;
Step :
Uncomment the block below and submit code for grading. Note that the
submission passes the "Compare output" test, but fails each unit test.
cout endl;
cout "Unknown function: PrintPlus endl;
cout "Secret string: abc endl;
After completing step :
Remove lines of code from step and implement the CallFunctionNamed
function above main
CallFunctionNamedprinter "PrintPlus;
CallFunctionNamedprinter "PrintPlus;
CallFunctionNamedprinter "PrintSecret";
return ;
LabPrinter.h
#ifndef LABPRINTERH
#define LABPRINTERH
#include
#include
class LabPrinter
protected:
const std::string secret;
public:
LabPrinterstd::string secretStringValue : secretsecretStringValue
virtual void PrintPlus
using namespace std;
cout endl;
virtual void PrintSecret
using namespace std;
cout "Secret string: secret endl;
;
#endif
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
