C The problem of an output result is very simple, I don t understand

Updated on society 2024-04-18
7 answers
  1. Anonymous users2024-02-08

    First of all, since 2 instances of the test class were created.

    So if you change test::test() to test::test() the result will be.

    constructor is active The constructor is called when the first class object [test[0]] is created.

    Constructor is active The constructor is called when the second class object [test[1]] is created.

    exiting main is executed to the cout statement in order.

    At the end of the program, the destructor is automatically called.

    destructor is active Parse created object 1destructor is active Parse created object 2

  2. Anonymous users2024-02-07

    You define an array of type test, test t[2].

    At the end of their living space, each of these two test objects calls the destructor test().

    So at the end of the main function, test() is called twice, and "destructor isactive" is displayed

  3. Anonymous users2024-02-06

    Program Start-> declares a test-type array, with two members-> outputs exiting main-> automatically calls the destructor before the end of the program, and outputs destructor is active twice

  4. Anonymous users2024-02-05

    Disagree with the statement of the first floor, variable i is still present after the end of the cycle. The problem is that the array pointer without a[i] is beyond the memory length originally allocated by a.

    According to the current **, this output should be a meaningless garbled or number.

    First, we define an array of 10 numbers, each of which is 0.

    Then the second number is assigned to 1 and the third number to 2 until the 10th number is assigned to 9.

    The problem is that after the 9th cycle, the value of i is already 10 after i++, and the condition of i<10 is not satisfied, and the cycle ends. At this time, it makes no sense to output a[i], which is a[10]. Because this array has only 10 numbers, there are only a[0], a[1].

    a[9]。a[10] does not exist, and if a[10] is forcibly output, it will only output the contents of the next unit of the array pointer in memory, which is meaningless for the program itself.

    If you modify ** slightly, change a[i]=i; and coutfor(int i=1; i<10;i++)

    a[i]=i;

    cout "In this case, it makes sense, which is equivalent to an output of each loop, then it will output a[1], a[2].a[9].There is a carriage return between each number (because there is "The last question of the landlord again, what does 1245120 represent?). 1245120 represents the contents of the next unit of memory space occupied by your memory, the A array, and then converted to int intger, what is the content of the next unit of memory space occupied by the array? No one knows, there is no point in this program anymore.

    And different computers run this program to get different results, I just tried once, and my output is 1365420.

    The other 2nd floor copied the paragraph I don't know where it came from**,Doubt.。。。

  5. Anonymous users2024-02-04

    After the for loop is executed, i does not exist, and a[i] cannot be referenced. The program exits incorrectly.

  6. Anonymous users2024-02-03

    0256 is an octal number.

    256 is the decimal number, and the corresponding octal number is 400

    The output is therefore 256 400 out of choice

  7. Anonymous users2024-02-02

    The output is:

    thisis"ax"

    Yes, the escape character will be output"。

    101 is an octal escape character whose value is equal to 65 in decimal (which is the ASCII code of the letter A), so the output is A.

    0 is an escape character, which means that the output ends here, and the subsequent ones will not be output again.

    So, the output is: thisis"ax"

Related questions
9 answers2024-04-18

Use that is the antecedent is a person or thing, whose is the object in the sentence, who is the subject, what is the antecedent is a thing, when is an adverb of time, which "which one (class) (one)". >>>More

13 answers2024-04-18

Why do people live?

Just saw it from The Reader. >>>More

14 answers2024-04-18

The result of running on vc++2005 is 002222

This kind of thing will get different values in different systems, garbage questions, don't bother. >>>More

8 answers2024-04-18

It's nonsense to say so much above. Landlord please see: pay attention to your program: printf("%d,%d",(a,b),(b,a); >>>More

15 answers2024-04-18

Early periods do not affect the safe period. According to the day you said, the 21st ML is within the safe period. It is not possible to get pregnant during the safe period, but the premise is that the safe period contraceptive method is only suitable for women who have a stable period. >>>More