Hello all together , I had to make a task and have some compiler errors
Header
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
|
#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_ */
|
cpp
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 70
|
#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;
}
|
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
|
#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);
}
|
Description Resource Path Location Type
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
Description Resource Path Location Type
conversion from 'int' to non-scalar type 'CTeam' requested CTeamTable.cpp /CTeam line 56 C/C++ Problem
Description Resource Path Location Type
conversion from 'int' to non-scalar type 'CTeam' requested CTeamTable.cpp /CTeam line 57 C/C++ Problem
Description Resource Path Location Type
no match for 'operator==' (operand types are 'CTeam' and 'int') CTeamTable.cpp /CTeam line 68 C/C++ Problem
Description Resource Path Location Type
within this context CTeamTable.cpp /CTeam line 61 C/C++ Problem
Description Resource Path Location Type
within this context CTeamTable.cpp /CTeam line 64 C/C++ Problem
Can somebody help me to solve the Compiler problems ?
I use Eclipse