|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
class beispiel
{
private:
char* Name = new char[20];
char* Name1 = new char[20];
public:
void ausgabe(char* aName = new char[20], char* aName1 = new char[20])
{
Name = aName; Name1 = aName1;
cout << aName << endl << aName1 << endl;
}
};
int main()
{
beispiel A("Wort deiner Wahl", "Wort deiner Wahl1");
A.ausgabe;
return 0;
|
So ich habs mal etwas geordnet
Das Problem ist, dass du den Konstruktor von beispiel mit Parametern aufrufst, dieser ist aber nicht definiert. Du meinst wohl:
|
C-/C++-Quelltext
|
1
2
|
beispiel A;
A.ausgabe("Wort deiner Wahl", "Wort deiner Wahl1");
|
Zudem ist der ganze Kram mit new superduper schlecht. Wo ist das passende delete[]? Ich sehe du inkludierst std::string, also benutze den auch:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
class beispiel
{
private:
string Name;
string Name1
public:
void ausgabe(string aName, string aName2)
{
Name = aName; Name1 = aName1;
cout << aName << endl << aName1 << endl;
}
};
int main()
{
beispiel A;
A.ausgabe("Wort deiner Wahl", "Wort deiner Wahl1");
return 0;
|
So ich habs mal etwas geordnet
Das Problem ist, dass du den Konstruktor von beispiel mit Parametern aufrufst, dieser ist aber nicht definiert. Du meinst wohl:
|
C-/C++-Quelltext
|
1
2
|
beispiel A;
A.ausgabe("Wort deiner Wahl", "Wort deiner Wahl1");
|
Schau dir auch mal 'const' an.