C about the question of citation, what is a citation in C?

Updated on technology 2024-02-09
6 answers
  1. Anonymous users2024-02-05

    Understand the following rules: 1) Overloading an operator does not change the priority of the operator.

    2) Overloading operators does not change the binding properties of the operators.

    3) Overloaded operators should not change the meaning of operators.

    The above rules are not mandatory, but they are best followed.

    So the binding of overloaded ++ (prefix) ++ suffix (hereafter denoted by int) is still ++ r—l)++int)(l—r); where r—l represents right-to-left bonding; ++ has a higher priority than ++(int), and for the ordinary ++ (the operation is to directly change the value of the operand, and ++(int) needs to record the value of the operand first, and then change the value, based on this consideration and the above rules can do this is & (citation), so use ++ (to use a reference, and ++(int) does not use!)

    Explanation: ++ (for the prefix ++, int) for the suffix ++;

    The above is my own understanding, and the explanation is not very clear

  2. Anonymous users2024-02-04

    It's just a return to the reference type.

  3. Anonymous users2024-02-03

    It can be operated continuously, such as ++ (clock).

  4. Anonymous users2024-02-02

    Reference is an important extension of C++ to the C language. References introduce a synonym for an object. Defining a reference is represented in a similar way to defining a pointer, except with a & instead of *, for example: point pt1(10,10).

    point &pt2=pt1;, defines pt2 as a reference to pt1. By such a definition, pt1 and pt2 represent the same object.

    It is important to emphasize that a reference does not produce a copy of an object, it is only a synonym for an object, and the reference must be initialized immediately at the time of definition, because it must be a synonym for something.

    Loop structure:

    The loop structure can reduce the workload of repeated writing of the source program, and is used to describe the problem of repeatedly executing a certain algorithm, which is the program structure that can give full play to the computer expertise in program design, and there are four kinds of loops provided in the C language, namely goto loop, while loop, do while loop and for loop.

    The four loops can be used to deal with the same problem, and they can generally be substituted for each other, but the goto loop is generally not recommended, because forcing a change in the order of a program often introduces unpredictable errors to the program's operation.

    It is especially important to include statements in the loop body that tend to end (i.e., changes in the value of the loop variables), otherwise it may become an endless loop, which is a common mistake for beginners.

  5. Anonymous users2024-02-01

    Foreshadowing: A variable name is essentially an alias for a continuous piece of storage space, which is a label.

    Variables are used to request and name memory spaces.

    You can use the storage space by the name of the variable.

    Can you make a name based on the name? )

    Concept: 1) It can be thought of as an alias for a defined variable.

    Citations are a grammatical category of C++, and you can no longer think about problems in C (indirect modifications).

    It is an extension of C from the C++ compiler.

    References are used as function arguments

    Significance of the quote

    References exist as aliases for other pointer variables, so they can be used as an alternative to pointers in some cases.

    Citations are more readable and useful than pointers.

    The essence of the citation

    What is the work behind the scenes of the C++ compiler.

    When defined individually--- it must be initialized, much like constants.

    1) References are implemented internally in C++ as a constant pointer.

    2) The C++ compiler uses constant pointers as the internal implementation of the reference during compilation, so the reference occupies the same space as the pointer.

    3) From a usage point of view, the quote can be mistaken for being just an alias and has no storage space of its own, which is a detail hidden by C++ for the sake of utility.

    Conclusion: When we use the syntax of references, we don't have to worry about how the compiler references are done.

    When we analyze strange syntax phenomena, we think about how the compiler does it.

    The function return value is a reference (when the reference is an lvalue).

    Difficulties in using C++ references:

    When the function returns a value as a reference, if the stack variable is returned, it cannot be the initial value of other references and cannot be used as an lvalue.

    If a static or global variable is returned, it can be the initial value for other references.

    It can be used as an rvalue or as an lvalue.

    Pointer references.

    The const constant in C++.

    Memory space may or may not be allocated.

    When the stst constant is global and needs to be used in other files, space is allocated.

    In the & operator, take the address of the const constant, which will be assigned.

    When a st-modified reference is configured, it is assigned.

    Conclusion: General quote ==int const e

    When initializing a const reference with a constant, the compiler allocates space for the constant value and alias the space with the reference name.

    Once the versus reference is initialized with literals, a read-only variable is generated.

  6. Anonymous users2024-01-31

    A reference is a new concept introduced in C++, denoted by the symbol &, which is an alias for an object, just like our nickname, which refers to the object itself and does not occupy the object's storage space.

    The pointer itself is a variable, which needs to allocate storage space, which stores the address of the object, and obtains the object address through the pointer variable, and can access and operate the object through the object address, so both the reference and the pointer can access the object, and the role is similar.

    There are pointers in both C and C++.

    There is no such concept of reference & in the C language, so there is no talk about how to represent it, where the object needs to be accessed, such as passing the object into the function for processing, in the C language you can directly use the pointer: linklist * l, in C++ you can use linklist * l or linklist & l, their effects are the same, the operation of the line parameters in the function body will change the value passed by the function as a real argument.

Related questions
9 answers2024-02-09

Scope. You static char *chh;

static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More

6 answers2024-02-09

Define the struct:

typedef struct _legaladdress_{ >>>More

9 answers2024-02-09

However, it is clear that this is problematic because variable a is not assigned at all. >>>More

14 answers2024-02-09

First question: What does exit failure mean? Why do you need this thing in this program? >>>More

7 answers2024-02-09

Do it by your train of thought.

Method 1. string strnumber="200m"; >>>More