-
static casting problem
hey every1
slight problem with casting if u could spare the time to have a quick look and c wat is going wrong
thanks alot
Code:
class JppVariable{
public:
string name;
string type;
};
class JppSimple: public JppVariable{
public:
int simple;
JppSimple(string _name, string _type, int _value);
};
JppSimple::JppSimple(string _name, string _type, int _value){
name = _name;
type = _type;
simple = _value;
}
//small but simple inheritance tree
//later i try this
vector <JppVariable> Variables;
JppSimple test = JppSimple("anything", "SIMPLE", 5);
Variables.push_back(test);
JppSimple temp = static_cast<JppSimple>(Variables[0]);
i thought that this should work but i get two errors:
error C2440: 'static_cast' : cannot convert from 'class JppVariable' to 'class JppSimple'
error C2512: 'JppSimple' : no appropriate default constructor available
can anyone tell me where i am going wrong
thanks for your time
rxg00u
-
what does this part do:
class JppSimple:
maybe u ment class JppSimple
{
//or...
//...i dont know
}
-
im not sure
sorry but im not sure i know what u mean?
ClassJppsimple extends JppVaraible and has the paramerters shown above and the constructor above sorry if this is not what you meant.
rxg00u
:D :D
-
send your entire code i think i know the problem (if u havent solved it yet)
please let me know if u have
-
hi soory for disturbing u ,
however i hav not solved it but i have approached it a diffrent way i now am using pointers to store in my vector for some reason casting pointers works better than casting actual objects ( do u know a reason for this as it would be a good bit of knowledge), anyway thanks for ur time and all ur help
yours pants
(rxg00u)