C variable problem, referential variable c c

Updated on technology 2024-05-11
16 answers
  1. Anonymous users2024-02-10

    Although both car and bus inherit from the same parent class, extending them separately can result in rich and different subclasses, such as adding a weight member variable as you said, and the member variables of the two subclasses are irrelevant. call, for example:

    car g_car;

    bus g_bus;

    g_;g_;

    Suppose getweight returns the weight of the car, then the car returns its own weight, and the bus returns the weight of the bus, and the two have nothing to do with each other.

    In addition, you can add other member variables or functions to the two subclasses to suit your needs.

  2. Anonymous users2024-02-09

    Each class can have its own members, which can have the same name, and is a matter of scope.

  3. Anonymous users2024-02-08

    You don't know much about object-oriented programming yet! It is recommended to read more books! Write more and practice more!

    Each class has its own members (variables. functions) and do not affect each other! Can have the same name!

    When using objects of different classes, you can use this variable correctly! Of course, if you set it to private, you can't use it externally! Can only be used in this category!

  4. Anonymous users2024-02-07

    You have to understand the problem with C++ namespace.

    Two classes can have the same data members and functions. Both. The class names themselves make up their respective namespaces.

    Other than that. namespace a

    class ca

    namespace b

    class cb

    It is also permissible.

    Summary: You should take a good look at the class and namespace definitions in C++.

  5. Anonymous users2024-02-06

    Two variables with the same name will be distinguished according to the different scopes...

  6. Anonymous users2024-02-05

    Scope and namespace.

  7. Anonymous users2024-02-04

    The short, int, long, and long long types use different numbers of bits to store values (you know the concept of bits for yourself) and can represent up to 4 different integer widths. C++ provides a flexible standard segment that ensures a minimum length (borrowed from C) as follows:

    1.short at least 16 bits.

    2.The int is at least as long as the short.

    3.long is at least 32 bits and at least as long as int.

  8. Anonymous users2024-02-03

    A reference type is really an alias.

    For example, int a = 0;

    int& b = a;

    Using B is equivalent to using A.

    Personally, I think there is a reference call to a function.

    It is also possible that some variables have difficult names to remember, but they cannot be changed, so they give them an easy alias.

  9. Anonymous users2024-02-02

    Static variables, which are initialized only once. So here b is defined only once.

    So 1 will be occupied, but very little. It's pretty much the same as the global variable definition.2 No, because there are no multiple definitions, only one definition.

    3 Aside from the life cycle, the biggest difference is the scope.

    Local variables can only be accessed within a function, while global variables can be accessed by anyone, which can easily lead to confusion, especially in the case of multithreading.

    In addition, non-static local variables are released after the function exits, and if all variables are defined as global, it is obviously a waste of memory.

  10. Anonymous users2024-02-01

    Function: It is a set of operations, such as eating, it can be eating rice, it can be eating noodles, you can eat a bowl, you can also eat half a bowl, there are different ways to eat different things to eat, this content is the parameter of the function, and different operations are performed by judging the different parameters.

    A variable is a container that records a certain data, such as a bowl, which can indicate that there is half a bowl of rice or a bowl of rice left in the bowl through the difference in variable values, or you can add half a bowl of rice to this bowl by calculating the variable.

    It's very abstract to say, and it's not as fast as learning the program directly.

  11. Anonymous users2024-01-31

    Variables are used to store data, while functions are used to process data.

  12. Anonymous users2024-01-30

    For example, y=x*2;That's the function.

    Among them, cai, x y are all variables.

  13. Anonymous users2024-01-29

    Upstairs, it's mixed upstairs.,for,while, although I don't know C++,But I also know that it's a loop statement.,Not a definition variable.。

  14. Anonymous users2024-01-28

    You have to have a header file first, and then type for , while, and that's it.

  15. Anonymous users2024-01-27

    I remember that it was in the book, and I checked it for you in the evening, and now I'm at work.

  16. Anonymous users2024-01-26

    It's more practical for you to look up online or buy books.

Related questions
15 answers2024-05-11

If the assignment is equal to 0, it is true, and if it is not equal to 0, it is false.

13 answers2024-05-11

In fact, this is a simple question of variable type and variable function, I think it should be explained like this: first, the original purpose of variable definition is to use the variable we define to meet the needs of our program, so, above you define variable a, then later, you will use this variable to do some operations, in most cases, it is to be initialized, so, give a corresponding type of value to initialize the variable, so that some operations can be used in the future, second, the understanding of that sentence:" You want a to represent 5, so you want to assign the value of a to 5", in fact, it is an initialization process of the variable a, where a is int (integer), corresponding to an initial value of 5, which is expressed like this: >>>More

7 answers2024-05-11

A local variable (an internal variable) is defined inside a function, and its scope is limited to the variable inside the function that defines it. >>>More

18 answers2024-05-11

Absolutely. The reason why it is a variable is that its value can be changed all the time, so that it can be called a variable. >>>More

21 answers2024-05-11

Friend, let me tell you what's good, the version you're using and this M2 is blue, it's not the same at all, and I think you put the horse's head on the cow's body, and it must be a little inappropriate. >>>More