Hallo all together,
In our C++/MFC project we have the following structure:
class A {
public:
bool FileExists(...);
};
class B {
public:
bool FileExists(...);
};
class C {
public:
bool FileExists(...);
};
In some classes there is the same function which checks the existence of a XML file.
But the classes are too different to create a base class to store the function.
So we decided to write "FileExists" as a global function and put it into
stdafx.cpp which is now our global function storage.
My question:
The advantage of an "old" language like C++ allows the usage of
global functions and variables, with leads to its disadvantage that object orientation
is broken.
What other stategies are available to solve the upper "problem" ?
And how can it be solved in languages like C# or Java in which global stuff is forbidden ?
Best regards