void Say () {
printf (the age of%s is%d, the result is%f\n ", name, age, score);
}
STU1, STU2;
At this point you can also omit the class name and create the object directly. As shown below:
class{
//member variable
char *name;
int age;
float score;
member function
void Say () {
printf (the age of%s is%d, the result is%f\n ", name, age, score);
}
STU1, STU2;
The direct definition of the object, which is legal and allowed in C + +, is rarely used and
Initialization and features of static members in the C ++ class
Some member variables in the C ++ class are initialized differently from those in the general data type. The following test compilation environment is:
➜ g++ -vUsing built-in specs.COLLECT_GCC=g++Target: x86_64-linux-gnugcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
Test code (compiled by g ++ ):
# Include
These special types of member variables mainly include:
1. Referenc
Commands for adding log groups and log members in oracle 1. Adding a log group: alter database add logfile group 4'/oradata/oracle/oradata/oracle_sid/redo04.log 'size 100 M; 2. Change the log group size (First, check the archiving status: SQL> select group #, thread #, members, archived, status from v $ log; www.2cto.com GROUP # THREAD # members arc status ------
All class members defined before the public members of the implementation class belong to the category of public members. any instance of the class openly discloses these attributes and methods. Private members of the implementation class are members that can be shared in th
[. NET Object-oriented Programming fundamentals ] (9) members of the class (fields, properties, methods)The class of the person previously defined includes the following members: Fields, properties, methods, events , and so on, in addition, the nested class that is mentioned earlier is also a member of the class. A. The members of a class are divided: static and
Object-oriented deep learning after class (detailed explanation of static members of class C ++)
I just applied for a blog today and wrote the essay all afternoon. So I decided to come to the end of c ++ and I will take the exam next week, I don't know much about the static members of this category. I saw a very detailed blog on the Internet and took a look back.
In C ++, static
When writing programs, we can define their access levels by using different access modifiers on the members of the class.
Public members
Public members in C # provide the external interface of the class, allowing users of the class to access them from outside. Public members are decorated with the modifier, which is
Accessibility of members, membership assembly, static class, member static
Accessibility of members
CLR terminology
C # terminology
Description
Private
Private
Members can only be accessed by methods in the definition type or any mosaic type.
Family
Protected
A member can only be accessed by defining a type, any mosaic
Example 1 sun xinmiao octoct2727th 2009 Skyseraph
Example 1.0
# Include "iostream"
Class Point
{
Public:
Void output (){}
Static void init () {}// static function. It does not belong to a specific object. That is, when no Point object is generated, this class already exists in the code area of the program.
}
Void main ()
{
/* Method 1
Point pt; // construct an object
Pt. init ();
Pt. output ();
*/
// Method 2
Point: init ();/
Point: output (); // Error
}
Note: method 1 is correct; method 2 is i
To use reflection to dynamically call class members, you need a method of the type class: invokemember. The statement for this method is as follows:
Public object invokemember (
String name,
Bindingflags invokeattr,
Binder binder,
Object target,
Object [] ARGs
);
Parameters
Name
String, which contains the name of the constructor, method, attribute, or field member to be called.
-Or-
An empty string ("") indicates the
Section 7 -- static member of the class -- ClassesandObjectsinPHP5 [7]. Section 7: static members of a class are different from those of a general class. static members are irrelevant to the instance of the object and only related to the class. they are used to implement the functions to be encapsulated and data Section 7-static members of the class
Static
When I saw muddle talking about testing non-public members in his blog, I suddenly thought that I had asked this question on csdn. At that time, I thought I would say, the test should also follow the OOP principle. I feel very touched and have a new view on this issue.
My current idea is that private members should not be tested.
First, nunit and other tools should be used to test External Interfaces. Esp
To use reflection to dynamically call class members, you need a method of the Type class: InvokeMember. The statement for this method is as follows (Excerpted from MSDN ):
Public object InvokeMember (
String name,
BindingFlags invokeAttr,
Binder binder,
Object target,
Object [] args
);Parameters
Name
String, which contains the name of the constructor, method, attribute, or field member to be called.
-Or-
An empty string ("") indicates the default Memb
(C #) use reflection to dynamically call class members To use reflection to dynamically call class members, you need a method of the Type class: InvokeMember. The statement for this method is as follows (excerpted from MSDN ):Public object InvokeMember (String name,BindingFlags invokeAttr,Binder binder,Object target,Object [] args);ParametersNameString, which contains the name of the constructor, method, at
JavaScript is the most misunderstood programming language in the world. Some people think it does not have the ability to "information hiding" because JavaScript objects do not have private variables and methods. This is a misunderstanding. JavaScript objects can have private members, so let's look at how to do that. (Sharkui.com Note: JavaScript does not really have proprietary, public, and so on OOP features, the proprietary, public, and privileged
When writing a program, it is inevitable to use static members. Because the access to static members is out of type objects, it is unreasonable to use non-static constructors, private methods, or some other methods .. NET provides the Member initialization statement and static constructor to initialize static members.
Based on the previous unit, we can know that
Java is an object-oriented language. It must be organized as an object during development.Code, Methods and attributes should belong to an object, rather than independent.
There is also a class of methods and attributes in Java. They do not belong to a specific object, but are shared by multiple objects. They are called static methods or static attributes.
1. Static attributes
Static attributes are shared by all objects of a class and are defined by the static keyword. The following code d
Access permission for C ++ protected members
The discussion on the access permissions of protected in C ++ is already a very old topic, and it is so old that everyone is reluctant to discuss it.
When I read c ++ primer again, the description of the protected member is as follows:
Protected members
The protected access label can be thought of as a blend of private and public:
like Private
source file (. h or. cpp, which is not available in other source files of the same source program ( Note that this is different from C + + ). Understanding of the C language static variable:A, if the global variable is only accessed in a single C file, you can modify the variable to a static global variable to reduce the coupling between modules;B, if the global variable is accessed only by a single function, then the variable can be changed to the static local variable of the function, in orde
PHP5 access allows you to restrict access to class members. This is a new feature in PHP5, but it already exists in many object-oriented languages. With access, you can develop a reliable object-oriented application and build a reusable object-oriented class library.Like C + + and Java, PHP has three ways to access it: public,private and protected. This can be one of the ways that a class member is accessed. If you do not specify the access method, th
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.