Z
Zero
Hello everyone,
here I have an example for heritage and I wonder
why the the object of type Down is able to change the private
attributes
from Above. Because I thought, when using heritage, the private
attributes
of Above are not useable. Can anybody remove my misunderstanding??
EXAMPLE:
#include <cstdlib>
#include <iostream>
using namespace std;
class Above
{
private:
int iTest1;
int iTest2;
public:
void setVars(int a, int b)
{
iTest1 = a;
};
};
class Down : public Above
{
};
int main(int argc, char *argv[])
{
Above a;
Down b;
b.setVars(4,5);
return EXIT_SUCCESS;
}
here I have an example for heritage and I wonder
why the the object of type Down is able to change the private
attributes
from Above. Because I thought, when using heritage, the private
attributes
of Above are not useable. Can anybody remove my misunderstanding??
EXAMPLE:
#include <cstdlib>
#include <iostream>
using namespace std;
class Above
{
private:
int iTest1;
int iTest2;
public:
void setVars(int a, int b)
{
iTest1 = a;
};
};
class Down : public Above
{
};
int main(int argc, char *argv[])
{
Above a;
Down b;
b.setVars(4,5);
return EXIT_SUCCESS;
}