Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania
Viewing all articles
Browse latest Browse all 65225

ocena programu, przez osobę bardziej doświadczoną w c++

$
0
0

Stworzyć klase która ma dwa pola(Class Element string nazwa;float cena)utworzyc konstruktor domyślny, parametryczny, domniemany. stworzyć funkcję publiczną która pozwala ustalić cene.

trzeba zastosować coś z tym bool  == dawałem juz podobne zadanie teraz podaje wam gotowy kod który się kompiluje. Nie hejtujcie jestem początkującym programistą

oto kod

#include <iostream>


using namespace std;



class Element
{
	public:
  string nazwa;
  float cena;
  

  Element()//konstruktor domyslny
  {
  	nazwa="pudlo";
  	cena=0;
  }
  
  Element(string n, float c)//konstruktor parametryczny
  {
  	nazwa=n;
  	
  	cena=c;
  }
  
  void ustaw_cene()
  {
  	cout<<"Nazwa elementu: "<<nazwa<<endl;
  	float cena;
  	cout<<"podaj cene ";
  	cin>>cena;
  
  
  }
 
  bool operator==(const Element& temp)
  {
    if((nazwa == temp.nazwa) && (cena == temp.cena))
      return true;
    return false;
  }
};
int main()

{
	Element e1;
	e1.ustaw_cene();
	
	
	
	return 0;

	
}

 


Viewing all articles
Browse latest Browse all 65225

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>