M
Michal
hallo group members, I wonder if the example below is consistent with a
C++ rules:
#include <iostream>
using namespace std;
class A {
};
class B: private A {
};
int main(int argc, char *argv[])
{
B *b = new B;
A *a = (A*)b;
A *c = b; /* produces follwowing error:
p5.cpp: In function "int main(int, char**)":
p5.cpp:15: error: "A" is an inaccessible base of "B"
What is the reason for it???
*/
return 0 ;
}
best regards,
Michal
C++ rules:
#include <iostream>
using namespace std;
class A {
};
class B: private A {
};
int main(int argc, char *argv[])
{
B *b = new B;
A *a = (A*)b;
A *c = b; /* produces follwowing error:
p5.cpp: In function "int main(int, char**)":
p5.cpp:15: error: "A" is an inaccessible base of "B"
What is the reason for it???
*/
return 0 ;
}
best regards,
Michal