Probleme bei speicherung
-
Ich hab dat Programm geschrieben:
header datei:#ifndef _vclassh_h_ #define _vclassh_h_ #include <stdio.h> #include <string.h> class DClass { private: struct Person { char name[20]; int alter; int datum; }; struct Datum { int tag; int monat; int jahr; }; public: DClass(); ~DClass(); inline void getdata (char *na, int al,int da); inline void getdata(int t,int m,int y); inline void putdata(); class DClass *next; }; DClass::DClass() { this->Person::alter = 0; this->Person::datum = 0; strcpy(this->Person::name," "); this->Datum::tag = 0; this->Datum::monat = 0; this->Datum::jahr = 0; } DClass::~DClass() { } void DClass::getdata(char *na, int al, int da) { this->Person::alter = al; this->Person::datum = da; strcpy(this->Person::name,na); } void DClass::getdata(int t,int m,int y) { this->Datum::tag = t; this->Datum::monat = m; this->Datum::jahr = y; } void DClass::putdata() { printf("%s\n",this->Person::name); printf("%d\n",this->Person::datum); printf("%d\n",this->Person::alter); printf("%d\n",this->Datum::tag ); printf("%d\n",this->Datum::monat); printf("%d\n",this->Datum::jahr ); } #endif cpp datei #include "vclassh.h" void main() { class DClass *prt; prt = new class DClass; prt->getdata("Test",12,345); prt->getdata(99,88,77); prt->putdata(); getchar(); }
nun irgendwie speichert er die variablen falsch bzw überschreibt und verändert sie wie bekomme ich das hin das der name auch unter Person::name und der tag unter Datum::tag zu finden ist? Danke euch schonmal.....
Mfg Uncle S.
<hume sagt>Bitte Code-Tags benutzen!</hume sagt>