// Class_return.cpp: defines the entry point of the console application.
//
# Include "stdafx. H"
Class class_return
{
Public:
Struct {
Int;
Int B;
};
Typedef struct a;
A AAA;
Public:
A geta () const;
Void Seta (a aa );
};
Void class_return: Seta (a aa)
{
AAA. A = AA.;
AAA. B = AA. B;
}
Class_return: A class_return: geta () const
{
Return AAA;
}
Int _ tmain (INT argc, _ tchar * argv [])
{
Class_return B;
B. AAA. A = 3;
B. AAA. B = 5;
B. Seta (B. AAA );
Printf ("% d, % d", B. Geta (). A, B. Geta (). B );
Return 0;
}
Class scope, the form parameter table function is in the scope, and the function return type is not necessarily in the scope. The purpose of this example is
Class_return: A class_return: geta () Const. Because the return value of this function is not in the scope, a class scope is added before;
Void class_return: Seta (a aa) because the form parameter is in the scope of the class, do not apply the class name to restrict the scope. However, struct like this
Struct {
Int;
Int B;
};
Typedef struct a;
This problem is generally defined as global.