我有一个类:在C++对象的正确铸造,值字段没有改变
class Para{
public:
int wrt, liczbaWystapien;
Para(){}
Para(int wrt, int liczbaWystapien){
this->wrt = wrt;
this->liczbaWystapien = liczbaWystapien;
}
然后是其他模板类,我不知道怎么投对象Para
,监守第一种方式根本不影响字段值。
else if (is_same<T, Para>::value){
//dynamic_cast<Node<Para>*>(node)->key.wrt++;//this way no error occured but value of field **wrt** stays the same
node->key.wrt++;//error below
Error 4 error C2039: 'wrt' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>
'
编辑:
节点* paraNode =的static_cast *>(节点); Para para = paraNode-> key; para.wrt = para.wrt + 1;
这让
错误 4错误C2440:'的static_cast:不能从转换“节点*”到“节点*”
感谢changin静态转换后我得到错误,请看看编辑。 – Yoda 2013-04-30 03:48:57