http://cpp0x.pl/kursy/Kurs-C++/Poziom-3 ... ejscia/351
mam problem:
z kodem:program8.cpp:6:33: error: declaration of ‘imie’ as array of references
program8.cpp:6:34: error: expected ‘)’ before ‘,’ token
program8.cpp:6:43: error: expected initializer before ‘&’ token
program8.cpp: In function ‘int main()’:
program8.cpp:28:61: error: cannot pass objects of non-trivially-copyable type ‘std::string {aka struct std::basic_string<char>}’ through ‘...’
program8.cpp:28:61: error: cannot pass objects of non-trivially-copyable type ‘std::string {aka struct std::basic_string<char>}’ through ‘...’
program8.cpp:31:60: error: cannot convert ‘std::string {aka std::basic_string<char>}’ to ‘std::string* {aka std::basic_string<char>*}’ for argument ‘1’ to ‘int wypiszOsobe(std::string*, std::string*, std::string*)’
Kod: Zaznacz cały
#include <iostream>
#include <string>
using namespace std;
int wczytajOsobe( string & imie[], string & nazwisko[], string & wiek[] ) {
cout << "Podaj imie dla osoby: ";
cin >> imie[];
cout << endl;
cout << "Podaj nazwisko dla osoby: ";
cin >> nazwisko[];
cout << endl;
cout << "Podaj wiek dla osoby: ";
cin >> wiek[];
}
int wypiszOsobe( string imie[], string nazwisko[], string wiek[] ) {
cout << "Imie: " << imie << endl;
cout << "Nazwisko: " << nazwisko << endl;
cout << "Wiek: " << wiek << endl;
}
int main() {
string imie[ 2 ];
string nazwisko[ 2 ];
int wiek[ 2 ];
for( int i = 0; i < 2; i++ )
wczytajOsobe( imie[ i ], nazwisko[ i ], wiek[ i ] );
for( int i = 0; i < 2; i++ )
wypiszOsobe( imie[ i ], nazwisko[ i ], wiek[ i ] );
return 0;
}