Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- class Produs{
- private:
- char nume[100];
- float pret; //fara TVA, in Euro
- static float PROCENT_TVA;
- static float CURS_VALUTAR;
- public:
- Produs(char *nume, float pret);//constructor
- //Produs(Produs &x); //constr copiere
- //~Produs();
- void citire();
- void afisare();
- static float getCURS_VALUTAR();
- static void setCURS_VALUTAR(float CURS_VALUTAR);
- float getPretCuTVA(){
- return pret*(1+PROCENT_TVA);
- }
- float getPretLeiCuTVA(){
- return getPretCuTVA()*CURS_VALUTAR;
- }
- };
- float Produs::PROCENT_TVA = 0.19;
- float Produs::CURS_VALUTAR = 4.7;
- Produs::Produs(char *nume, float pret){
- strcpy(this -> nume, nume);
- this -> pret = pret;
- }
- void Produs::afisare(){
- printf("Nume: %s\n", nume);
- printf("Pret in Euro fara TVA: %g\n", pret);
- //printf("Pret in Euro cu TVA: %g\n", getPretCuTVA());
- printf("Pret Lei cu TVA: %g\n", getPretLeiCuTVA());
- }
- int main(){
- Produs p1("CPU", 100);
- Produs p2("HDD", 200);
- p1.afisare();
- p2.afisare();
- Produs:: PROCENT_TVA = 0.25; Inaccesibil!
- Produs::setTVA(0.25);
- p1.afisare();
- p2.afisare();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement