Class scope, the form parameter table function is in the scope, and the function return type is not necessarily in the scope

Source: Internet
Author: User

 

// 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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.