2016-04-05 8 views
0

std::shared_ptrを基本クラスにスタティックキャストしようとしています。クラスを考える:エラーC2065: 'static_pointer_cast':宣言されていない識別子 - Visual Studio 2010

std::shared_ptr<ImportFileSettingSelect> selectedSheet_ = std::make_shared<ImportFileSettingSelect>(); 
std::vector<std::shared_ptr<ImportFileSetting>> settings_; 
settings_.push_back(static_pointer_cast<ImportFileSetting>(selectedSheet_)); 

私はcppreference.comに応じた:

class ImportFileSetting {}; 
class ImportFileSettingSelect:ImportFileSetting {} 

私は、次のコードを試してみました。しかし、コンパイルに失敗します:

5>src\TechAdminServices\database\techCore\processes\ImportDataSourceExcel.cpp(32): error C2065: 'static_pointer_cast' : undeclared identifier 
5>src\TechAdminServices\database\techCore\processes\ImportDataSourceExcel.cpp(32): error C2275: 'ImportFileSetting' : illegal use of this type as an expression 
5>   d:\techsys\techadmin\techadminservices\src\techadminservices\database\techcore\processes\ImportFileSetting.h(7) : see declaration of 'ImportFileSetting' 

どうすればこの問題を解決できますか?

答えて

1

あなたが不足している名前空間:

settings_.push_back(std::static_pointer_cast<ImportFileSetting>(selectedSheet_)); 
//     ^^^^^