Hi folks, I tried to read some past threads in this forum but I didn't find one that solves the problem I'm dealing about.
I have experience with Java/OO programming and I'm developing a project using C++ (I have some background with C/C++ programming but I'm messing around some issues of the C++ language).
Well let's go to the problem:
My application uses the Model/View/Controller pattern and since I'm trying to add a ProgressBar to my "View" module I'm using the Observer Pattern, so I created two classes (I'd refer it as "interfaces")
class AbstractObserver {
public:
virtual void update(int progressStatus) = 0;
};
class AbstractSubject {
public:
virtual void registerObserver(AbstractObserver* observer) = 0;
virtual void removeObserver(AbstractObserver* observer) = 0;
virtual void notifyObserver() = 0;
};
Since my "View"class (named IMDialog) is the Observer, it extends the "AbstractObserver" class, and so implements the "update(int progressStatus)" method. Ex:
#include "AbstractObserver.h"
#include "IupDialogWrapper.h"
class IMDialog : public AbstractObserver, public IupDialogWrapper {
public:
void update(int progressStatus) {
cout << "IMDialog: " << progressStatus << endl;
}
// another methods of the IupDialogWrapper class..
}
In another class, such as the controller class, I did a simple test, trying to invoke the method in the following way:
IMDialog *frontEnd = new IMDialog();
frontEnd->update(42);
The code compiles and links perfectly, but when the method "void update(int progressStatus)" is called the application terminates with an error. (actually it is not been called).
I realized that if I make another class as the Observer, which has the signature:
class AnotherClass: public AbstractObserver {
public:
void update(int progressStatus) {
cout << "AnotherClass: " << progressStatus << endl;
}
};
the method "void update(int progressStatus)" can be invoked, is it a problem of "multiple inheritance" or something like this? The way I'm invoking the method "frontEnd->update(42);" is wrong? I tried doing some cast, as well as dynamic_cast<>() with no sucess.
Sorry for the whole history, but I tried to explain the plot.
Thanks,
Eduardo