2013-01-10 86 views
0

我正在使用Visual C++。你能否以这种语法提供帮助?错误表达式

class CVisionSystem 
    { 
    public: 
CVisionSystem(); 
~CVisionSystem(void); 


int Init(); 


    private: 

PvDevice device; 
// PvStream object 
     PvStream stream; 
// Buffer 

    CustomPipeline *pipeline; 

// GEV Parameters 
PvGenParameterArray *deviceParams; 
    PvGenInteger *parTLLocked; 

}; 

int CVisionSystem::Init() 
{ 
deviceParams = device.GetGenParameters();  
parTLLocked = dynamic_cast<PvGenInteger *>(deviceParams->Get("TLParamsLocked")); 

} 

deviceParms得到有效价值,但parTLlocked获取导致错误NULL值:“错误表达无法计算,_vfptr CX0030和mthis CX0076

什么可以ParTLLocked的问题

+1

'deviceParams->获取(“TLParamsLocked”)'不能被强制转换为'PvGenInteger *' –

+0

这将有很大的帮助,如果你说你正在使用的库。 – molbdnilo

回答

1

我猜deviceParams->Get("TLParamsLocked")返回一个不能被动态转换成PvGenInteger *的类型返回类型应该是指向一个子类或者父类PvGenInteger(或者可能是同一个类)的指针,空值

+0

那么,有什么可以解决的?并请再次查看编辑的问题 – Nabeel

+0

请至少添加class heirarchy,以便我可以回答您的问题。 –

+0

我希望我编辑dat问你问。 – Nabeel

1

如果dynamic_cast无法转换为目标类型,则返回空值。你应该检查这个。

对于动态转换成功,被转换的对象必须在其继承树中的某处存在目标类类型。这就是目标类型必须是运行时对象的实际类型或其父类之一。这意味着您只能向下转换实际为目标类型的对象。

+0

如果你用简单的话来解释它会很好。我很抱歉,我没有得到你的答案 – Nabeel

0
PvGenParameterArray *lDeviceParams = d->lDevice.GetGenParameters();  
lTLLocked = dynamic_cast<PvGenInteger *>(lDeviceParams->Get("TLParamsLocked"));