1

私はこれを行おうとしています(カスタムクラスとSTL shared_ptrを使用して#include <memory>):

shared_ptr<Label> BufLbl;

BufLbl = allocate_shared<Label>(Label());
BufLbl->YCoord = 3;
BufLbl->XCoord = 2; 
BufLbl->Width = 5;
BufLbl->Data = "Day 1";
Screen.Controls.push_back(BufLbl);

BufLbl = allocate_shared<Label>(Label());
BufLbl->YCoord = 4;
BufLbl->XCoord = 6; 
BufLbl->Width = 1;
BufLbl->Data = "2";
Screen.Controls.push_back(BufLbl);

<repeat>

このエラーが発生します:

error C2903: 'rebind' : symbol is neither a class template nor a function template

私は何が間違っているのですか?

4

1 に答える 1

2

あなたは虐待していますallocate_shared、それはあなたが思っていることではありません。

必要なのはmake_shared、次のようなものです。

BufLbl = std::make_shared<Label>();
于 2012-11-13T04:07:04.513 に答える