Questions about Arrays and Pointers

Asked 2 years ago, Updated 2 years ago, 23 views

class Simple {
private:
    int arr[len];
};

If such a class has an array as a member variable,

Will the objects in this class have an array within the object?

Or is it in the form of arr pointing to an array stored in an arbitrary place outside the object?

I'm a little confused because I heard that arrangement and pointer have the same concept.

c++

2022-09-22 13:56

1 Answers

There is no class purely from the point of view of the system (assembly).

Simply, a stack is what you need to call a function, and a heap is what you need to store objects of any size.

From a c++ perspective, it's either an array within an object or a stack from an assembly perspective.

Creating an example with c++ and looking at the assembly code while debugging is also a big lesson.


2022-09-22 13:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.