wäre nett, wenn mir da jemand helfen könnte.
danke..
*******************************************************************************/
#include <iostream>
#include <conio.h>
using namespace std;
/*******************************************************************************
Prototypfunktions - und Klassendefinitionen
*******************************************************************************/
class CFeld {
char *cp;
int dim;
public:
CFeld(){cp=0;}//Standardkonstruktor
CFeld(char *p) {
dim=strlen(p)+1;
cp = new char[dim];
if(!cp){cout << "Fehler in new" <<endl; exit(1);}
}
~CFeld(){delete []cp;}//Destruktor
CFeld(const CFeld &a);//Kopierkonstruktor
CFeld & operator=(const CFeld &a);
friend ostream& operator<<(ostream& os, CFeld cp);
};
//Kopierkonstruktor
CFeld::CFeld(const CFeld &cf){
int i;
dim = cf.dim;
cp = new char[cf.dim];
if(!cp) exit(1);
for(i=0;i<cf.dim;i++) cp=cf.cp[i];
cout <<"Aufruf Kopierkonstruktor" << endl;
}
CFeld & CFeld::operator=(const CFeld &cf){
int i;
dim = cf.dim;
cp = new char[cf.dim];
if(!cp) exit(1);
for(i=0;i<cf.dim;i++) cp[i]=cf.cp[i];
cout <<"Aufruf =operator" << endl;
}
ostream& operator<<(ostream& out, CFeld p){
out <<p.dim<<endl;
return out;
}
/*******************************************************************************
Hauptprogramm
*******************************************************************************/
int main() {
cout <<"Test"<<endl;
CFeld einCFeld("Halllo!");
cout <<"Test"<<endl;
CFeld zweitesCFeld("xxxxxx");
cout <<"Test"<<endl;
cout << einCFeld;
cout <<"Test"<<endl;
zweitesCFeld = einCFeld;
cout <<"Test"<<endl;
cout <<zweitesCFeld;
cout <<"Test"<<endl;
CFeld drittesCFeld = einCFeld;
cout <<"Test"<<endl;
cout << einCFeld;
cout <<"Test"<<endl;
getch();
return 0;
}