Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class meteo{
- private:
- int br;
- float temp;
- int *niz;
- int duz;
- public:
- meteo(){
- niz=0;};
- ~meteo(){
- delete []niz;
- niz=0;
- }
- meteo(int a,float b,int *c,int d){
- br=a;
- temp=b;
- duz=d;
- niz=new int[duz];
- for(int i=0;i<duz;i++)
- niz[i]=c[i];
- }
- meteo(const meteo &a){
- temp=a.temp;
- br=a.br;
- duz=a.duz;
- niz=new int[a.duz];
- for(int i=0;i<duz;i++){
- niz[i]=a.niz[i];
- }
- }
- void setBr(int a){
- br=a;
- }
- void setTemp(float b){
- temp=b;}
- int GetBr(){
- return br;
- }
- int GetTemp(){
- return temp;
- }
- void Stampaj(){
- cout<<"Temp"<<temp<<" "<<"broj"<<" "<<br<<" "<<"duzina"<<duz<<endl;
- for(int i=0;i<duz;i++)
- cout<<niz[i]<<" "<<endl;
- }
- friend meteo operator+(meteo,meteo);
- };
- meteo operator+(meteo a,meteo b){
- int m=0;
- int *y=new int[a.duz+b.duz];
- for(int i=0;i<a.duz;i++){
- y[m++]=a.niz[i];
- }
- for(int i=0;i<b.duz;i++){
- y[m++]=b.niz[i];
- }
- meteo rez(a.br,a.temp,y,m);
- return rez;
- }
- int main()
- {
- int a,c,d,e;
- float b;
- cout<<"Unesi broj i temperaturu"<<endl;
- cin>>a>>b;
- cout<<"Unesi duzinu niza"<<endl;
- cin>>d;
- int *x=new int[d];
- cout<<"UNESI podatke promjene temp"<<endl;
- for(int i=0;i<d;i++){
- cin>>e;
- x[i]=e;
- }
- meteo a1(a,b,x,d);
- a1.Stampaj();
- cout<<"Unesi broj i temperaturu"<<endl;
- cin>>a>>b;
- cout<<"Unesi duzinu niza"<<endl;
- cin>>d;
- int *y=new int[d];
- cout<<"UNESI podatke promjene temp"<<endl;
- for(int i=0;i<d;i++){
- cin>>e;
- y[i]=e;
- }
- meteo a2(a,b,y,d);
- a2.Stampaj();
- meteo a3;
- a3=a1+a2;
- a3.Stampaj();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement