I have been given this code with the restraints that i can not edit the public in anyway and am not allowed to call any other library's other than the ones specified.
Class example
{
private:
vector<int> vector_1;
void function_1(string name)
{
"code for function one goes here"
}
public:
void function_1(string name);
};
is there way to map function_1 to a method in private? so that in main: a method call would act like it was it was in public however it is in private (considering the constraints)
-edit: i have read the rules and research a bit however could not find a true answer to what i was looking for. Here is the code sample:
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class MapFunction
{
private:
string responce;
string input;
vector<int> templist;
public:
void AskForInput();
void Output(string input)
};
int main(void) {
MapFunction a;
return 0;
}
The restraints of my solution is that i am not allowed to make changes to the public section of the class or put code into main. Normally i would create the method inside of the class by creating a method like this
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class MapFunction
{
private:
string responce;
string input;
vector<int> templist;
public:
void AskForInput(void);
void Output(void);
};
void MapFunction::AskForInput() {
cin >> input;
};
void MapFunction::Output() {
cout << input;
};
int main(void) {
MapFunction a;
a.AskForInput();
a.Output();
return 0;
}
however i wondering if it was possible to place the methods inside private and allowing main to access them without changing the way it is called in public