class A{
private:
std::vector<class X> flavor1
std::vector<class X> flavor2
public:
void useVectorOfX(std::vector<class X> someflavor){
... // same logic for both flavors
}
}
Now I want to call useVectorOfX() from another class, giving it either flavor1 or flavor2 depending on need. I can think of three ways –
Way 1: Use Getter Methods; but it seems unnatural for class A to get its own data through a Getter Method.
class B{
public:
A *a = new A();
a->useVectorOfX(a->getFlavor1());
}
Way 2: Make the two vectors public (dirty)
Way 3: Separate Methods?
class B{
public:
A *a = new A();
a->useVectorOfXForFlavor1();
a->useVectorOfXForFlavor2();
}
What about way 1 in a more descriptive format: