The previous article explained step one "C + + Grade Test" ___ Choice question I know how to deal with the choice question, how much time to leave the choice question. Now, let's talk about step two and deal with the big questions .
Second, basic operation problem (18 points)
This type of topic is not everyone play to find your sister Game, the only difference is that the problem not only to you to find fault and to be corrected, the knowledge point is still unchanged
I enumerate one or two for your reference.
The definition of a friend function is consistent with the declaration.
Friendvoid Increment (myclass& f)
Voidincrement(MyClass & F) {f._i++}
Friend function calls, not classes, so you don't need to add class names and scopes when you call the META function
The initialization of a const data member can only be done through the constructor's member initialization list, and using the keyword const adornment,
MyClass (int i=0): NUM (0)
Allocate space, use the strcpy function to copy strings, such as Writer=newchar[strlen (The_writer) +1] Note that the size of the allocated space should be the length of the string plus 1
The definition of the Const member function, which cannot be changed, must be initialized.
constructor function
Constant variable Private member, when initialized, can only be initialized by a member list
Private:
Const int radius;
Public:
Circle (int R): radius{} When defining a class's member function, add the class name and scope
Void cricle::D isplay ()
Use the identifier "." When calling member functions.
Constructors, like destructors, do not need to add any type
Overloaded functions are a special case, convenient to use, the formal parameters of these functions with the same name, the number of parameters. Type or order) must be different,
The use of virtual functions, base classes, and derived classes. When calling a method of a virtual function, you should call the function method of the derived class to get
Transmit value (value), address, and pass-through reference (reference)
When passing a value, the child function (callee) copies the value passed by the parent function (the caller), and the function cannot change the value of the parent function variable. The first parameter of a function swap is a value call, so its value does not change
The parent function passes the address of the variable to the child function, so that the function can rewrite the contents of the address to change the variables in the parent function.
............
............
............
300 words are omitted here ...
It's still the same thing.
———————— This article is for reference only, knowledge is accumulated by the usual ——————
We learn together and make progress together.
"C + + Grade Test" ___ Basic Operation questions