Witam mam problem chcialem wyswietlic skladowa mark obiektu s2 . Niestety nie wyswietla sie . Macie jakis pomysl jakbym mogl to naprawic ?
#include <iostream>
using namespace std;
class samochod{
string* mark;
string mode;
double przebie;
public:
samochod():mark(new string),mode("0"),przebie(0){}
samochod(const string& m,const string& mo,const double km):mark(new string(m)),mode(mo),przebie(km){}
string marka(){return* mark;}
const string marka()const{return *mark;}
string& model(){return mode;}
const string& model()const{return mode;}
double& przebieg(){return przebie;}
const double& przebieg()const{return przebie;}
friend ostream& operator << (ostream& out,const samochod& car);
samochod& operator = (const samochod& sam);
// samochod operator +( double l)
};
ostream& operator << (ostream& out,const samochod& car)
{
out << *car.mark << " " << car.mode << " " << car.przebie ;
return out;
}
samochod& samochod:: operator = (const samochod& sam){
*mark = *sam.mark;
mode=sam.mode;
przebie = sam.przebie;
return *this;
}
int main()
{
samochod s1("fiat","palio",100);
cout << s1.marka() << s1.model() << s1.przebieg() << endl;
samochod s2;
cout << s1 << endl;
s2.marka() = "Opel";
s2.model() = "Astra";
s2.przebieg() = 300;
cout << s2 << endl;
samochod s3 = s2;
cout << s3 << endl;
s3 = s1;
cout << s3 << endl;
/*samochod s4 = s3 + 1000;
cout << s4 << endl;*/
return 0;
}