Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
一定のサイズの配列があり、各セルに1つのID、1つのカウンター、およびポインターを配置するプログラムを実装する必要があります。私の質問は、1つの配列セルに複数の要素を配置する方法です。
このような:
struct Cell { Cell() : id(0), counter(0), pointer() {} int id, counter; std::unique_ptr<int> pointer; }; Cell cells[100];
次のような要素にアクセスできます。
cells[0].id = 1; ++cells[0].counter; cells[0].pointer.reset(new int(9));