#include <iostream>
using namespace std;
class A
{
private:
float data_member;
public:
A(int a);
explicit A(float d);
};
A::A(int a)
{
data_member = a;
}
A::A(float d)
{
data_member = d;
}
void Test(A a)
{
cout<<"Do nothing"<<endl;
}
int main()
{
Test(12);
Test(12.6); //Expecting a compile time error here
return 0;
}
I am expecting a error int this case as my CTOR that takes float value is explicit. But I am not getting any error in VS 2010. Please point me out if I am wrong with my understanding of keyword "EXPLICIT" in c++.