Naime ovaj kod radi kada stavim char * i to je ok , ali ne radi sa string ???
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
class cStudent
{
public:
cStudent(void);
cStudent(string , string , string , double);
void Ispisi(void);
void Upisi(string , string ,string , double );
cStudent * sljedi;
private:
string ime;
string prezime;
string id_st;
double prosijek;
};
cStudent::cStudent(void)
{
ime=" ";
prezime=" ";
id_st=" ";
this->prosijek=0;
}
cStudent::cStudent( string s1, string s2 ,string s3 ,double d1)
{
ime=s1;
prezime=s2;
id_st=s3;
prosijek=d1;
}
void cStudent::Upisi(string s1, string s2 ,string s3 ,double d1)
{
ime=s1; // Ovdije program puca
prezime=s2;
id_st=s3;
prosijek=d1;
}
void cStudent::Ispisi(void)
{
cout << this->ime << " " << this->prezime <<" " << this->id_st << " " << this->prosijek << endl ;
}
void main(void)
{
string v_ime;
string v_pre;
string v_broj;
double v_pros;
cStudent *pst=NULL ;
cStudent *pPocetak=NULL;
cStudent *ptemp=NULL;
int f=0;
while(f<3)
{
f++;
cout << "Unesi Ime Studennta :" ;
cin >> v_ime;
cout << endl;
cout << "Unesi Prezime Studennta :" ;
cin >> v_pre;
cout << endl;
cout << "Unesi Broj Studennta :" ;
cin >> v_broj;
cout << endl;
cout << "Unesi prosijek Studennta :" ;
cin >> v_pros;
cout << endl;
ptemp=pst;
pst=(cStudent*) malloc(sizeof(cStudent));
if(ptemp!=NULL)
{
ptemp->sljedi=pst;
}
if (pPocetak==NULL)
{
pPocetak=pst;
}
pst->Upisi(v_ime,v_pre,v_broj,v_pros);
pst->sljedi=NULL;
}
pst=pPocetak;
do
{
pst->Ispisi() ;
pst=pst->sljedi;
}while(pst!=NULL);
}
Samo mi nemojte reci " Vrati char , pa ce ti raditi " , HVALA