簡體   English   中英

C ++中的變量列表

[英]List of Variables in C++

有沒有一種方法可以創建類似std::vector列表,但是只包含1個值,並且沒有鍵。

我基本上想做的是存儲一堆實體。 如果可以通過鍵刪除對象,那也很好。 (例如map::remove(Entity*);

是。 它稱為std::set 它是某種類型的一組值。

例如:

  • std::set<int>將存儲int
  • std::set<Entity>將存儲Entity對象( Entity類型的實例)。
  • std::set<Entity *>將存儲指向Entity的指針。

我假設你的意思是std::map ,而不是std::vector

在這種情況下,您可以使用std::setstd::unordered_set

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM