I am currently using Clang on the latests OSX to build a static library in C++11 and came across something that seems odd to me.
I have class C that inherits from A and B. A is used as a public interface for the users of the class and B is used as an abstract implementation, holding methods that are common to all instances of A. I come from the Java world so I'm treating A as an interface and B as an abstract class.
In class C I have a method that is inherited from B that calls two private methods defined in C. And herein lies the weirdness. If I implement the inherited method like this:
bool EPubParser::isCorrectFileType() {
bool has_correct_file_type = false;
bool is_compressed_file = this->isCompressedFile();
if (this->hasRightExtension() && is_compressed_file) {
has_correct_file_type = true;
}
if (has_correct_file_type) {
LOG(DEBUG)<< "Has correct file type. " << endl;
} else {
LOG(DEBUG)<< "Does not have correct file type. " << endl;
}
return has_correct_file_type;
}
everything works fine. I can see log statements in this->isCompressedFile() being called. If I remove the temporary variable is_compressed_file and call this->isCompressedFile() directly in the condition, they don't get called. It's as if the method doesn't exist.
Am I missing something about C++? Is this a Clang bug? Is my Java background tripping me up?