Acess violation writing 0xcdcdcef#, objects within objects
Hey so I'm fairly new to C++ and I'm not sure why this is not working. I
have two classes, let's call them ned and myfile. I need to have two file
objects within each ned object. Here is a simplification:
class myfile {
public:
int nData;
int nHeaderSize;
myfile() {
nData=0;
nHeaderSize=0;
}
}
class ned {
public:
myfile *pSrc;*pTgt;
ned() {
myfile* pSrc = new myfile();
myfile* pTgt = new myfile();
}
}
int main(int argc, char* argv[]) {
ned* nedObj = new ned();
nedObj->pSrc->nData=5; //Access violation error here
}
This is obviously a simplified version but any ideas are appreciated. I
can add more code if the problem is not obvious from this small example.
No comments:
Post a Comment