Witam!
Stawiam pierwsze kroki w C++, bawiłem się ostatnio sporo w C# w którym mogłem odpocząć od wskaźników, dziś znowu się z nimi mierzę. I według mnie to ich wina!(wcale nie moja ;) )
A więc pojawia się takie błędy:
||=== Build: Debug in 1.5 Praca na strukturach - student (compiler: GNU GCC Compiler) ===|
32|undefined reference to LoadingData(int, Student)'| 33|undefined reference to
ShowingData(int, Student)'|
||error: ld returned 1 exit status|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
po wycięciu z logów adresów plików.
A sam kod wygląda następująco:
#include <iostream>
#include <string>
using namespace std;
struct Student
{
string imie;
string nazwisko;
int pierwszaOcena;
int drugaOcena;
int trzeciaOcena;
float srednia;
};
void LoadingData(int, Student);
void CountingAverage(int, Student);
void ShowingData(int, Student);
int main()
{
int amount;
float averge;
cout << "Witaj w programie ktory policzy srednia dla studentow zdajacych 3 egzaminy w sesji!" << endl;
cout << "Ilu jest studentow? ";
cin >> amount;
Student* studenci = new Student[amount];
cout << "Teraz bedziesz proszony o podanie kolejnych informacji o kolejnych studentach!" << endl << endl;
LoadingData(amount, *studenci);
ShowingData(amount, *studenci);
return 0;
}
void CountingAverage(int amount, Student* studenci[])
{
for(int i = 0; i < amount; i++)
{
studenci[i]->srednia = ((float)studenci[i]->pierwszaOcena + (float)studenci[i]->drugaOcena + (float)studenci[i]->trzeciaOcena) / (float)(3);
}
}
void LoadingData(int amount, Student* studenci[])
{
for(int i = 0; i < amount; i++)
{
cout << "Podaj imie studenta nr. " << i + 1 << ":";
cin >> studenci[i]->imie;
cout << endl;
cout << "Podaj jego nazwisko";
cin >> studenci[i]->nazwisko;
cout << endl;
cout << "Podaj jego ocene z przedmiotu #1: ";
cin >> studenci[i]->pierwszaOcena;
cout << "Podaj jego ocene z przedmiotu #2: ";
cin >> studenci[i]->drugaOcena;
cout << "Podaj jego ocene z przedmiotu #3: ";
cin >> studenci[i]->trzeciaOcena;
}
}
void ShowingData(int amount, Student* studenci[])
{
for(int i = 0; i < amount; i++)
{
cout << "Student #" << i + 1 << ". " << studenci[i]->imie << " " << studenci[i]->nazwisko << ", ma srednia: " << studenci[i]->srednia << endl;
}
}
Szczerze nie mam pojęcia co sknociłem. I w jaki sposób to naprawić.. Jakieś porady?