Zwracanie parametru struktury przez funkcje typu void.

0

Witam.
Mój program ma pobierać informacje o studencie i zwracać je przez parametr typu Student. Co w nim jest nie tak?

#include <iostream>
#include <string>

using namespace std;

struct Student {
    string nazwisko;
    string imie;
    float ocenaDyp; //ocena na dyplomie
    bool czyOplata;
};

void Wczytaj( Student dane )
{
    cin >> dane.nazwisko;
    cin >> dane.imie;
    cin >> dane.ocenaDyp;
    cin >> dane.czyOplata;
   
}
void Wyswietl( Student dane )
{
    cout << dane.nazwisko;
    cout << dane.imie;
    cout << dane.ocenaDyp;
    cout << dane.czyOplata;
}
int main()
{
   
    Wczytaj();
    Wyswietl();
   
   
}

0
Wczytaj();
    Wyswietl();

Nie masz nawet zdefiniowanych takich funkcji.
Program nie powinien się skompilować.
https://wandbox.org/permlink/CAELX8H0ijjNXGXu

0

Teraz jest dobrze?


#include <iostream>
#include <string>

using namespace std;

   struct Student {
string nazwisko;
string imie;
float ocenaDyp; //ocena na dyplomie
bool czyOplata;
};

 void Wczytaj(Student & dane)
 {

    cin>>dane.nazwisko;
    cin>>dane.imie;
    cin>>dane.ocenaDyp;
    cin>>dane.czyOplata;

 }
 void Wyswietl (Student dane)
 {
     cout<<dane.nazwisko;
     cout<<dane.imie;
     cout<<dane.ocenaDyp;
     cout<<dane.czyOplata;
 }
int main()
{
    Student x;
    Wczytaj(x);
    Wyswietl(x);


}

1
void Wyswietl (const Student &dane) {}

będzie dobrze.

1 użytkowników online, w tym zalogowanych: 0, gości: 1