-
1 You can't declare or define a given default value at the same time, you can only choose one of the two, otherwise an error will be reported.
2 The general non-reference and non-pointer const type parameters are not overloaded flags, if there are two functions with the same name, and there is a non-pointer or non-reference parameter, one is const, and the other is not const, an error will be reported, for example, <1>, if it is a reference or pointer, the one with and without const can be overloaded, and one of the two corresponding calls according to the type of the argument const or non-const, for example, <2>, <3>4 The reason is that both *a and *const a can point to a non-const int, *const a means that you can't point to other values after initialization, so if there is a call? Therefore<4> error is reported.
In fact, it can be understood that calling a function with arguments is equivalent to initializing the parameters, and when the types provided by the arguments in the call statement initialize the parameters of two functions with the same name: when one is valid and the other is not, the call is legitimate; If it is all legal, it depends on whether there is an implicit conversion, and there is no need for an implicit conversion, such as "4", if there is an implicit conversion, it depends on the conversion level, and if the conversion level is low, if the conversion level is the same, an error will be reported.
-
Example: int f(int x, int y); This is the function declaration statement that tells the program to call the rules after that.
int f(int x,int y) This is the body of the function that states the statement that the function executes.
Not allowed: (because it is stated that two inconsistent compilers will not be able to handle it).
int f(int x=0,int y=0);This is the function declaration statement that tells the program to call the rules after that.
int f(int x=0,int y=0) This is the body of the function, which states the execution statement of the function.
only: int f(int x=0, int y=0); This is the function declaration statement that tells the program to call the rules after that.
int f(int x,int y) This is the body of the function that states the statement that the function executes.
or: int f(int x, int y); This is the function declaration statement that tells the program to call the rules after that.
int f(int x=0,int y=0) This is the body of the function, which states the execution statement of the function.
That is, these rules apply when you call a function with a variable (or function return value) as an argument; The examples are all different functions, and you can write these two functions at the same time in the program, and the compiler determines which one to call according to the type of variable to call. And I call int add(int a, int b) with add(1,2); and int add(const int a, const int b); There is no difference.
-
1. Generally, the default value is specified when declaring, that is, in the header file. I haven't tried to specify the default value in cpp, according to your understanding, it should be okay to choose 1 of the 2. But both are specified, and the compiler certainly doesn't know which is correct, so it doesn't pass.
2. If you think, the form parameter is not a pointer or a reference, but it is actually a copy of the value, and it has nothing to do with the original parameters. The original parameters will not be modified, so it doesn't matter if you use consult or not. Pointers and references must be classified as "const" and "non-const" because they can modify the object they were pointing to.
First. Solution: Because a(n+1)=a(n)+1 (n(n+1)), so a(n+1)-a(n)=1 (n(n+1)) so a(n)-a(n-1)=1 (n(n-1))a(n-1)-a(n-2)=1 ((n-1)(n-2))a(2)-a(1)=1 (2*1). >>>More
You don't know anything about lawyers?! Want to be a lawyer? >>>More
Are you talking about this star, it's just that someone else's logo is designed like this, and the deep meaning is probably only known to the designer. >>>More
Start your day with a delicious breakfast. If you can eat a delicious breakfast in the morning, the day's work and study will become extraordinarily energetic. However, many people's breakfast is not up to standard, and even some people do not eat breakfast, such as vertical selling cong, which not only lacks nutrition, but also easily leads to stomach problems. >>>More
1.Imagine a cube with a regular shape, submerged in water, its 6 faces are subject to the pressure of water, because its left and right sides, the front and rear sides of the surface under the water depth is the same, then the pressure of the water is also the same, the pressure is equal in size, the direction is opposite, balanced with each other, and the upper and lower sides are in different depths in the water, the pressure of the water is small, the pressure is also different, the lower surface is subjected to the upward pressure of the water f is greater than the upper surface by the pressure of the water f downward. The net force of the pressure on the object is the buoyant force of the liquid on the object. >>>More