[ create a new paste ] login | about

Link: http://codepad.org/wcbQQ4KL    [ raw code | output | fork ]

C++, pasted on Jan 20:
#include<iostream>
#include<cstring>
using namespace std;

class Disk
{
    private:
    char proiz[30];
    float gb;
    int mb;
    int cena;
    public:
     Disk(){}
    Disk(char *proiz1,float gb1,int mb1,int cena1)
    {
        strcpy(proiz,proiz1);
        gb=gb1;
        mb=mb1;
        cena=cena1;
    }
    ~Disk(){}
    char *getproiz(){return proiz;}
    float getgb(){return gb;}
    void setproiz(char *proiz1){strcpy(proiz,proiz1);}
    void setgb(float gb1){gb=gb1;}
    int getcena(){return cena;}

    virtual int cenaf()=0;
    virtual void pecati()=0;


};
class CD:public Disk
{
     private:
     bool brish;
    public:
      CD(char *proiz1,float gb1,int mb1,int cena1,bool brish1):Disk(proiz1,gb1,mb1,cena1)
      {
          brish=brish1;
      }
      friend bool operator==(CD & a,CD & b)
      {
          return (strcmp(a.getproiz(),b.getproiz()));
      }
      int cenaf()
      {
          float cena;
          cena=getcena();
           cena=getcena()/(getgb()*1024);
           if(brish)
           return (cena*2);
           return cena;

      }

     void pecati()
     {
         cout<<"CD(Princo,"<<gb*1024*1024*1024<<"MB,"<<cenaf()<<"denari"<<endl;
         if(brish)
         cout<<"RW"<<end;
         else cout<<"r"<<end;
     }
};
class Blurey:public Disk
{
     private:
     int sloj;
     public:
     Blurey(char *proiz1,float gb1,int mb1,int cena1,int sloj1):Disk(proiz1,gb1,mb1,cena1)
     {
         sloj=sloj1;
     }
     friend bool operator==(Blurey & a,Blurey & b)
     {
         return (strncpy(a.getproiz(),b.getproiz()));

     }
     float cenaf()
     {   int mba;
         int cena=getcena();
         mba=getgb()*1024*1024*1024;
         cena*=sloj;
         return (cena/mba);
     }
     void pecati()
     {
         cout<<"Blueray(JVC,"<<getgb()<<"GB"<<getmb()<<"Mb/s"<<cenaf()<<"Denari"<<sloj<<"sloja"<<endl;

     }
};
int main()
{
    return 0;
};


Output:
1
2
3
4
5
6
7
cc1plus: warnings being treated as errors
t.cpp: In member function 'virtual int CD::cenaf()':
Line 52: warning: converting to 'int' from 'float'
Line 53: warning: converting to 'int' from 'float'
t.cpp: In member function 'virtual void CD::pecati()':
Line 9: error: 'float Disk::gb' is private
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: