Consider the code below and suppose that several years after; a colleague adds a new implementation of SetRotationSpeed(int i)
in a DLL knowing that, the code of the class containing the implicit conversion has been compiled in static mode.
There will be no compilation errors except that it may change the behavior of the program, which in my opinion constitutes a potential danger to the behavior of the program.
Has the C++ standard thought about this edge effect?
In this topic, I am not particularly interested in the use of the explicit keyword but in an edge effect that we can encounter on a program developed in the form of separated DLLs by several developers who do not necessarily know each the part developed by the other one.
#include <iostream>
#include <string>
using namespace std;
class A
{
public:
A(int n)
: m_RotationalScannerSpeed(n/2)
{
std::cout << "Scanner Rotation speed"<< m_RotationalScannerSpeed<<endl;
}
private:
int m_RotationalScannerSpeed;
};
void SetRotationSpeed(A a){
};
// Function added 2 years later by a collegue in a DLL...
/*void SetRotationSpeed(int i){
};*/
int main (int argc, char* argv[])
{
int i=5;
SetRotationSpeed(i);
}