What is the reason which why this code compile :
#include <iostream>
using namespace std;
class being {
public:
void running(char c) {
cout << "No one know ";
}
};
class human :public being {
public:
using being::running;
void running(char y) {
cout << "I am a human";
}
};
int main() {
human o;
o.running('A');
return 0;
}
the output : "I am a human"
I mean ( I am expecting having error (redefinition function in human class )) like this : this code compile :
#include <iostream>
using namespace std;
class being {
public:
int v;
};
struct human :public being {
public:
double v;
};
int main() {
human o;
o.v = 55.2;
return 0;
}
but when i add ( using being::v )
#include <iostream>
using namespace std;
class being {
public:
int v;
};
struct human :public being {
public:
using being::v;
double v;
};
int main() {
human o;
o.v = 55.2;
return 0;
}
the error appear: error C2086: 'int being::v': redefinition
why this error did not appear in the first code ?