I'm working on a new application, based on templates, STL, namespaces, ... (my collegues have taken all necessary steps to make a mess), now I just want to add a property to a class, and this does not work, let me show you):
Within a header-file:
namespace utils{
class Logging_Manager : public Singleton<Logging_Manager> {
friend Singleton<Logging_Manager>;
Logging_Manager();
private:
std::vector<std::shared_ptr<Single_Logger>> logging_modules;
LogLevelType loglevel; // 0 : no logging, 1 : info logging, (2-4 are not used), 5 : debug, 6 : everything
public:
Timer getDebuggerTimer;
Timer getFileTimer;
I've just added the last entries getDebuggerTimer
and getFileTimer
myself and this does not compile, due to the compiler errors C3646 and C4430.
All I mean is that both are properties of the type Timer
, I don't mean those things to be templates of some methods which might be abstract, virtual, or whatsoever, no they are just to meant as properties, nothing more nothing less.
As I didn't find a way to add both timers to my header file, my boss has just solved the issue as follows:
class Timer; // this class is defined elsewhere, how can it be put here and make things work?
namespace utils{
class Logging_Manager : public Singleton<Logging_Manager> {
friend Singleton<Logging_Manager>;
Logging_Manager();
private:
std::shared_ptr<Timer> getDebuggerTimer;
std::shared_ptr<Timer> getFileTimer;
In other words: he did not add an inclusion, but he added a reference to something the header does not know: class Timer
.
In top of this, he added a shared pointer, which magically did something.
I'm completely lost here: it looks like STL has added programming rules like:
- In case you want something to work, don't add an inclusion, but add a reference (but how does your code know what the reference means?)
- You can add shared pointers (or other STL inventions), who will make your code work.
?????
Can anybody shed a light to this?