W
Wilson
hi. Again trying to understand inheritcance but can't see what is
wrong with this small peice of code below to test my knowledge. When
complied it simply returns the "system("PAUSE")" and nothing else. I
cant understand why that is. Please help.
wilson
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
class account
{
public:
int balance, number;
virtual int function() { return balance; }
};
class checking : public account
{
public:
int balancechecking;
};
class savings : public account
{
public:
int balancesavings;
};
void display(account& x)
{
x.function();
}
int main()
{
savings a;
checking b;
b.balance = 10;
a.balance = 20;
display(a);
cout << endl;
display(b);
system("PAUSE");
}
wrong with this small peice of code below to test my knowledge. When
complied it simply returns the "system("PAUSE")" and nothing else. I
cant understand why that is. Please help.
wilson
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
class account
{
public:
int balance, number;
virtual int function() { return balance; }
};
class checking : public account
{
public:
int balancechecking;
};
class savings : public account
{
public:
int balancesavings;
};
void display(account& x)
{
x.function();
}
int main()
{
savings a;
checking b;
b.balance = 10;
a.balance = 20;
display(a);
cout << endl;
display(b);
system("PAUSE");
}