- Μορφοποιημένος Κώδικας: Επιλογή όλων
-
#include <iostream>
using namespace std;
class Test
{
public:
int sum;
Test();
~Test();
};
class Test2
{
public:
Test a;
Test b;
Test2();
~Test2();
};
class Test3
{
public:
Test test2;
Test3();
~Test3();
int increase(int i, int j);
};
int main()
{
Test3 test3;
test3.increase(5,6);
return 0;
}
int Test3::increase(int i , int j)
{
a.sum=i;
b.sum=j;
}
Αλλά μoυ βγάζει οτι την συνάρτηση increase a.b not declared in this scope.
Στην ουσία θέλω μια κλάση (1) να έχει το sum μετά μια κλάση (2) να καλεί 2 object της κλάσης (1) και στην συνέχεια μια κλάση (3) να καλεί την κλάση (2) και την συνάρτηση.


