最近我刚开始学习数据结构和算法,我一直在想为什么数组是一种数据结构,而对象不是。因为我们知道一个对象将保存数据,然后具有像数组一样操作它们的功能。我已经用谷歌搜索过了,但是我还没有找到答案。如果有人能解释这一点,我将不胜感激。这是一个与我的问题相关的问题,希望这能更好地澄清我的问题https://www.reddit.com/r/learnprogramming/comments/pmv63n/why_is_an_object_not_a_data_structure/
您可以在这里查看有关数据结构类型的更多信息https://www.google.com/amp/s/searchsqlserver.techtarget.com/definition/data-structure%3famp=1
发布于 2021-10-20 15:03:02
我不知道数据结构实际上是为C++定义的,但如果我正确理解了您的问题,我将如何区分。
数组是一种保存数据的容器。数组的实例是一个对象,它是数组数据结构的特定用途。
// Instantiation of a vector object - the object itself is not a 'data structure' it is a specific use of a data structure
std::vector <int> x = {1, 2, 3};
// The data structure itself is just std::vectorhttps://stackoverflow.com/questions/69648239
复制相似问题