Can we agree that:
- a method is a function which is member of a class
and:
- if a function is declared outside a class, it’s better to refer to it simply as a ‘function’ ?
If we agree with what above:
So TJM is a namespace so I believe that means if I put methods inside of TJM then I can access those methods from outside of my current class with the :: |
The namespace doesn’t modify the ‘traditional’ way to access class members.
To invoke a non static method you need a class instance; to invoke a static method, you anyway need the class name.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
namespace vysero {
struct MyClass {
void method_a();
static void method_b();
};
// From inside namespace vysero:
MyClass my_instance;
my_instance.method_a();
MyClass::method_b();
} // end namespace vysero
// From outside namespace vysero:
vysero::MyClass my_instance;
my_instance.method_a();
vysero::MyClass::method_b();
|
bpa().firmwareVersion() means: "Go to the bpa() class |
I apologize for the following stupid questions, but they are quite typical in guessing games:
Are you sure TJM is a namespace?
Are you sure in that namespace there’s declared a class bpa?
Are you sure bpa() is not just a function (no matter if member of a class or not)?
About your second snippet...
It’s possible that both bpa and BpaProvider were part of an inheritance chain, so that sdm() and dynamicSdm() return instance of different classes, in the same chain, which expose different versions of firmwareVersion()... Who knows?
But, from my limited experience, is not that common that trained programmers adopt inconsistent naming conventions, such as calling some classes with a capitalized name and others with a lowercase initial.
What about adding some code (an entire header, for example)?