Registrierung Kalender Mitgliederliste Teammitglieder Suche Häufig gestellte Fragen Zur Startseite

Informatiker Board » Themengebiete » Praktische Informatik » C++ 2 » Antwort erstellen » Hallo Gast [Anmelden|Registrieren]

Antwort erstellen
Benutzername: (du bist nicht eingeloggt!)
Thema:
Nachricht:

HTML ist nicht erlaubt
BBCode ist erlaubt
Smilies sind erlaubt
Bilder sind erlaubt

Smilies: 21 von 33
smileWinkDaumen hoch
verwirrtAugenzwinkerngeschockt
Mit ZungeGottunglücklich
Forum Kloppebösegroßes Grinsen
TanzentraurigProst
TeufelSpamWillkommen
LehrerLOL HammerZunge raus
Hilfe 
aktuellen Tag schließen
alle Tags schließen
fettgedruckter Textkursiver Textunterstrichener Text zentrierter Text Hyperlink einfügenE-Mail-Adresse einfügenBild einfügen Zitat einfügenListe erstellen CODE einfügenPHP CODE farbig hervorheben
Spamschutz:
Text aus Bild eingeben
Spamschutz

Die letzten 10 Beiträge
progger

Alles klar danke .

Ich setz mich jetzt an eine neue Aufgabe.

Bis später .

Wenn ich wieder Hilfe brauche großes Grinsen
eulerscheZahl

Dann suche nach Compileroptionen (was zu tun ist, habe ich schon geschrieben) oder arbeite mit den Index.
progger

Description Resource Path Location Type
'nullptr' was not declared in this scope CTeamTable.cpp /CTeam2 line 50 C/C++ Problem

Description Resource Path Location Type
make: *** [CTeamTable.o] Error 1 CTeam2 C/C++ Problem


Diese 2 Fehler werdem mir noch angezeigt .

Wir müssen mit Eclipse programmieren.?
eulerscheZahl

Du kannst auch den Index speichern, wenn dir das lieber ist.
Die Erkennung eines Nichtfindens geht dann eben anders (z.B. über einen negativen Initialwert).
progger

CTeam* t1 = nullptr;
CTeam* t2 = nullptr;

Muss man das immer so machen ?
eulerscheZahl

Neben den Syntaxfehlern solltest du vielleicht auch die Mannschaften richtig schreiben.
Zitat:
table.addResult("Borussia Drotmund", "Werder Bremen", 1, 0);


Ich habe es compiliert mit
code:
1:
g++ -std=c++0x Main.cpp CTeam.cpp CTeamTable.cpp

Wenn du einen älteren Standard nimmst, ist nullptr nicht bekannt.

Dateianhang:
zip infoboard.zip (3 KB, 352 mal heruntergeladen)
progger

Jetzt noch mal der komplette Code .

Damit jemand der sich mal mit der Aufgabe beschäftigt ,den Überblick hat.

Allerdings sind im code noch fehlermeldungen vorhanden großes Grinsen
Header CTeamTable
code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:

#ifndef CTEAMTABLE_H_
#define CTEAMTABLE_H_
#include<iostream>
#include "CTeam.h"
#include <stdio.h>
#include <string.h>
using namespace std;

class CTeamTable {
private:
	CTeam* m_pTable;
	unsigned int m_maxEntry;
	unsigned int m_curEntry;

public:
	CTeamTable(int unsigned maxEntry);
	~CTeamTable();
	bool addTeam(CTeam const& team);
	void print(string headline);
	bool addResult(string team1,string team2,unsigned int goalsTeam1, unsigned int goalsTeam2);
	void sort();


};

#endif /* CTEAMTABLE_H_ */



CTeamTable cpp

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
#include "CTeamTable.h"
#include "CTeam.h"
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;

CTeamTable::CTeamTable(int unsigned maxEntry = 10){
	if (maxEntry < 5){
		maxEntry = 5;
	}
    m_maxEntry = maxEntry;
    m_curEntry = 0;
    m_pTable = new CTeam[m_maxEntry];

}

CTeamTable::~CTeamTable(){
	delete[] m_pTable;
}

bool CTeamTable::addTeam(CTeam const& team) {
	if (m_curEntry >= m_maxEntry) {
		return false;
	}
	m_pTable[m_curEntry++] = team;
	return true;
}

void CTeamTable::print(string headline) {
	cout << headline << endl;
	for (int i = 0; i < m_curEntry; i++) {
   		cout << i+1 << " - " << m_pTable[i];
	}
	cout << endl;
}

void CTeamTable::sort() {
	for (int i = 0; i < m_curEntry; i++) {
		for (int j = 0; j < m_curEntry - 1; j++) {
			if (m_pTable[j+1] < m_pTable[j]) {
				CTeam tmp = m_pTable[j];
				m_pTable[j] = m_pTable[j+1];
				m_pTable[j+1] = tmp;
			}
		}
	}
}
    CTeam t1 = NULL;
	CTeam t2 = NULL;
bool CTeamTable::addResult(string team1,string team2,unsigned int goalsTeam1, unsigned int goalsTeam2){

	for (int i = 0; i < m_maxEntry; i++) {
		if (strcmp(m_pTable[i].m_teamName, team1) == 0) {
			t1 = m_pTable[i];
		}
		if (strcmp(m_pTable[i].m_teamName, team2) == 0) {
			t2 = m_pTable[i];
		}
	}
	if (t1 == NULL || t2 == NULL) return false; //Team nicht gefunden
	t1.addResult(goalsTeam1, goalsTeam2);
	t2.addResult(goalsTeam2, goalsTeam1);
	return true;

	}



main:

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
#include "CTeamTable.h"
#include "CTeam.h"
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;

int main2(){

	CTeam bayern("Bayern München");
		CTeam bvb("Borussia Dortmund");
		CTeam werder("Werder Bremen");
		bayern.addResult(3,3);
		bayern.addResult(1,4);
		werder.addResult(3,3);
		bvb.addResult(4,1);
		CTeamTable table(3);
		table.addTeam(bayern);
		table.addTeam(werder);
		table.addTeam(bvb);
		table.print("Unsortierte Tabelle");
		table.sort();
		table.print("Sortierte Tabelle");

	table.addResult("Borussia Drotmund", "Werder Bremen", 1, 0);
}



Ist bei e) das hinzufügen der Teams einfach das hier?

table.addTeam(bayern);
table.addTeam(werder);
table.addTeam(bvb);




Diese Fehlermeldungen gehen nicht weg obwohl ich das string includiert hab?



Description Resource Path Location Type
'std::string CTeam::m_teamName' is private CTeam.h /CTeam line 17 C/C++ Problem
cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)' CTeamTable.cpp /CTeam line 61 C/C++ Problem
cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)' CTeamTable.cpp /CTeam line 64 C/C++ Problem
conversion from 'int' to non-scalar type 'CTeam' requested CTeamTable.cpp /CTeam line 56 C/C++ Problem
conversion from 'int' to non-scalar type 'CTeam' requested CTeamTable.cpp /CTeam line 57 C/C++ Problem
Invalid arguments '
Candidates are:
int strcmp(const char *, const char *)
' CTeamTable.cpp /CTeam line 61 Semantic Error
Invalid arguments '
Candidates are:
int strcmp(const char *, const char *)
' CTeamTable.cpp /CTeam line 64 Semantic Error
no match for 'operator==' (operand types are 'CTeam' and 'int') CTeamTable.cpp /CTeam line 68 C/C++ Problem
within this context CTeamTable.cpp /CTeam line 61 C/C++ Problem
within this context CTeamTable.cpp /CTeam line 64 C/C++ Problem
comparison between signed and unsigned integer expressions [-Wsign-compare] CTeamTable.cpp /CTeam line 39 C/C++ Problem
comparison between signed and unsigned integer expressions [-Wsign-compare] CTeamTable.cpp /CTeam line 46 C/C++ Problem
comparison between signed and unsigned integer expressions [-Wsign-compare] CTeamTable.cpp /CTeam line 47 C/C++ Problem
comparison between signed and unsigned integer expressions [-Wsign-compare] CTeamTable.cpp /CTeam line 60 C/C++ Problem
No return, in function returning non-void CTeam.cpp /CTeam line 39 Code Analysis Problem
No return, in function returning non-void main2.cpp /CTeam line 15 Code Analysis Problem
'CTeam' is not derived from 'const std::allocator<_CharT>' CTeamTable.cpp /CTeam line 68 C/C++ Problem
'CTeam' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' CTeamTable.cpp /CTeam line 68 C/C++ Problem
'CTeam' is not derived from 'const std::basic_string<_CharT>' CTeamTable.cpp /CTeam line 68 C/C++ Problem
'CTeam' is not derived from 'const std::fpos<_StateT>' CTeamTable.cpp /CTeam line 68 C/C++ Problem
'CTeam' is not derived from 'const std::istreambuf_iterator<_CharT, _Traits>' CTeamTable.cpp /CTeam line 68 C/C++ Problem
'CTeam' is not derived from 'const std::pair<_T1, _T2>' CTeamTable.cpp /CTeam line 68 C/C++ Problem
'CTeam' is not derived from 'const std::reverse_iterator<_Iterator>' CTeamTable.cpp /CTeam line 68 C/C++ Problem
mismatched types 'const _CharT*' and 'CTeam' CTeamTable.cpp /CTeam line 68 C/C++ Problem
template argument deduction/substitution failed: CTeam line 128, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\allocator.h
C/C++ Problem
template argument deduction/substitution failed: CTeam line 133, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\allocator.h
C/C++ Problem
template argument deduction/substitution failed: CTeam line 204, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\streambuf_it
erator.h C/C++ Problem
template argument deduction/substitution failed: CTeam line 214, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_pair.h C
/C++ Problem
template argument deduction/substitution failed: CTeam line 216, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\postypes.h C
/C++ Problem
template argument deduction/substitution failed: CTeam line 2486, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string
.h C/C++ Problem
template argument deduction/substitution failed: CTeam line 2493, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string
.h C/C++ Problem
template argument deduction/substitution failed: CTeam line 2507, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string
.h C/C++ Problem
template argument deduction/substitution failed: CTeam line 2519, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string
.h C/C++ Problem
template argument deduction/substitution failed: CTeam line 291, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator
.h C/C++ Problem
template argument deduction/substitution failed: CTeam line 341, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator
.h C/C++ Problem
candidates are: CTeamTable.cpp /CTeam line 68 C/C++ Problem
template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&) CTeam line 2507, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string
.h C/C++ Problem
template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) CTeam line 2519, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string
.h C/C++ Problem
template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&) CTeam line 2486, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string
.h C/C++ Problem
template<class _CharT, class _Traits> bool std::operator==(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&) CTeam line 204, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\streambuf_it
erator.h C/C++ Problem
template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::basic_string<_CharT>&, const std::basic_string<_CharT>&) CTeam line 2493, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string
.h C/C++ Problem
template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) CTeam line 291, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator
.h C/C++ Problem
template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) CTeam line 341, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator
.h C/C++ Problem
template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&) CTeam line 216, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\postypes.h C
/C++ Problem
template<class _T1, class _T2> bool std::operator==(const std::allocator<_CharT>&, const std::allocator<_T2>&) CTeam line 128, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\allocator.h
C/C++ Problem
template<class _T1, class _T2> bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) CTeam line 214, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_pair.h C
/C++ Problem
template<class _Tp> bool std::operator==(const std::allocator<_CharT>&, const std::allocator<_CharT>&) CTeam line 133, external location: c:\program files\git\eclipse\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\allocator.h
C/C++ Problem
eulerscheZahl

Teamnamen (Plural).
table.addResult("Borussia Drotmund", "Werder Bremen", 1, 0);
progger

Was meinst du mit teamName als Argumente ?
eulerscheZahl

Die Instanz, übder die du die Funktion aufrufst, hat schon gepasst.
Die Teamnamen sollst du als Argumente übergeben.
Es sind weitere Beiträge zu diesem Thema vorhanden. Klicken Sie hier, um sich alle Beiträge anzusehen.