Hi, I'm an old fart in (C-)programming, but quite nooby in today's C++.
(Did little something with C++ at the end of of 80's.)
My question: what would be a good mechanism of hiding alternative
implementations in C++?
What I was thinking was a class - say "InOutClass".
The I/O would be done by passing the object of InOutClass to
other classes that need to input or output something.
Something like:
1 2 3 4 5 6 7 8 9 10
|
class InOutClass
{
private:
Context context;
public:
int Initialise();
int Write();
int Read();
int cleanup();
};
|
Then there could be different implementation classes, say
HTTP, file, RS232, ...
All the other classes see is InOutClass.
It looks like template needs that parameters visible in classes that use
the InOutClass and Inheritance goes the other way: specific class methods could be implemented in the general class.
In this case the general class methods should be implemented in a specific class.