You are on page 1of 1

#include <iostream>

using namespace std;

class Laptop
{
private:
char tipProcesor[20], producator[20];
int pret, RAM;

public:
friend ostream& operator<<(ostream&, Laptop&);
friend istream& operator>>(istream&, Laptop&);

};

ostream& operator<<(ostream& iesire, Laptop& L )


{
iesire<<"\n Tip procesor :"<< L.tipProcesor
<<"\t Producatorul :"<< L.producator
<<"\t Pret :"<< L.pret
<<"\t Capacitatea ram : "<<L.RAM;
return iesire;
}

istream& operator>>(istream& intrare, Laptop& L)


{
intrare>>setw(20)>>L.tipProcesor;
intrare.ignore(1);
intrare>>setw(20)>>L.producator;
intrare.ignore(1);
intrare>>setw(10)>>L.pret;
intrare.ignore(1);
intrare>>setw(10)>>L.RAM;
return intrare;
}
int main()
{
Laptop L1;
cout<<"\nIntroduceti informatiile despre laptopului dorit :";
cin>>L1;
cout<<"\nAfiseaza datele laptopului";
cout<<L1;

return 0;
}

You might also like