jak mam takie coś
to dlaczego jak pisze y.show() pojawia mi się jakaś dziwna liczbę i 10 a powinno byc 10 i 10.
#include <iostream>
using namespace std;
class test
{
private:
int x;
public:
virtual void fun(int a);
virtual void show(void) const;
//virtual void fun(int a, int b);
};
class test2 : public test
{
private:
int y;
public:
virtual void fun(int b);
virtual void show(void) const;
};
int main(void)
{
test x;
test2 y;
x.fun(10);
y.fun(10);
y.show();
// test & pe = y;
// pe.fun(10);
// pe.show();
}
void test::fun(int a)
{
x = a;
}
void test::show(void) const
{
cout << x << endl;
}
void test2::fun(int b)
{
y = b;
}
void test2::show(void) const
{
test::show();
cout << y << endl;
}