In the following program i can't access balance value of parent class in the child class. If the child class can access all attributes and methods of parent class, then why i am getting 0 value when i access parent class balance.
Anyone please help, my programming understanding is very little.
#include <iostream.h>
#include <conio.h>
class bal
{
public:
int balance;
bal()
{
balance = 0;
}
bal(int b)
{
balance = b;
}
void deposite()
{
balance += 3000;
}
int show()
{
return balance;
}
};
class childB: public bal
{
public:
void withdraw()
{
balance -= 500;
}
};
void main()
{
bal b(1000);
childB c;
cout << "balance from b : " <<b.show() <<endl;
cout << "balance from c : " <<c.show() <<endl;
getch();
}