PaulM1985
December 23rd, 2010, 03:55 PM
Hi all
This problem is something I have found while using Windows and Visual Studio, so I accept that this is not the correct forum, but since I know you people are good I was hoping this is a C++ problem, rather than something windows based.
I originally had a CircularPatternProcedure class which inherited from a ComponentProcedure class. Since I am going to add another type of circular procedure I have added an abstract CircularProcedure class, which inherits from the ComponentProcedure. CircularPatternProcedure now inherits from CircularProcedure.
CircularPatternProcedure had a function "bool GetFeatures(List &list) const" which took a list and added the features to it, returning true if features existed.
I moved GetFeatures to the abstract class, since I want to use polymorphism. I have labelled GetFeatures as virtual in both the abstract CircularProcedure class and the concrete CircularPatternProcedure class.
Here is my problem:
If I do
SomeOtherClass::SomeMethod(const CircularProcedure &circProc)
{
List list;
if (circProc.GetFeatures(list)) {
...
}
}
The call on GetFeatures correctly calls the code on the CircularPatternProcedure, however when I do:
CircularPatternProcedure::Build()
{
List list;
if (GetFeatures(list)) {
...
}
...
}
The call doesn't actually go to the GetFeatures function, it goes off to execute some other function in a different class ("Type Geometry2d::GetType() const", if you were wondering.)
Has anyone come across this before, and does anyone have any idea how to fix this? Is this likely to be a compiler/OS specific problem and this forum is completely the wrong place for such a question?
I am afraid this is actual work stuff, so I can't post real code, I can only give an example of what I am doing.
Paul
This problem is something I have found while using Windows and Visual Studio, so I accept that this is not the correct forum, but since I know you people are good I was hoping this is a C++ problem, rather than something windows based.
I originally had a CircularPatternProcedure class which inherited from a ComponentProcedure class. Since I am going to add another type of circular procedure I have added an abstract CircularProcedure class, which inherits from the ComponentProcedure. CircularPatternProcedure now inherits from CircularProcedure.
CircularPatternProcedure had a function "bool GetFeatures(List &list) const" which took a list and added the features to it, returning true if features existed.
I moved GetFeatures to the abstract class, since I want to use polymorphism. I have labelled GetFeatures as virtual in both the abstract CircularProcedure class and the concrete CircularPatternProcedure class.
Here is my problem:
If I do
SomeOtherClass::SomeMethod(const CircularProcedure &circProc)
{
List list;
if (circProc.GetFeatures(list)) {
...
}
}
The call on GetFeatures correctly calls the code on the CircularPatternProcedure, however when I do:
CircularPatternProcedure::Build()
{
List list;
if (GetFeatures(list)) {
...
}
...
}
The call doesn't actually go to the GetFeatures function, it goes off to execute some other function in a different class ("Type Geometry2d::GetType() const", if you were wondering.)
Has anyone come across this before, and does anyone have any idea how to fix this? Is this likely to be a compiler/OS specific problem and this forum is completely the wrong place for such a question?
I am afraid this is actual work stuff, so I can't post real code, I can only give an example of what I am doing.
Paul