31.12.2014 Views

Paskaitų konspektai - Matematikos ir Informatikos fakultetas ...

Paskaitų konspektai - Matematikos ir Informatikos fakultetas ...

Paskaitų konspektai - Matematikos ir Informatikos fakultetas ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Kadangi klas÷s Food <strong>ir</strong> Selling abi turi rodyklių viena į kitą, tai mums tenka viename<br />

iš failų (pas<strong>ir</strong>inkome selling.h) naudoti išankstinį klas÷s apibr÷žimą be jos kūno<br />

(class Food;).<br />

Vieno pardavimo metu užd<strong>ir</strong>btas pelnas n÷ra atsk<strong>ir</strong>ai saugomas. Jis apskaičiuojamas<br />

pagal kitus duomenis:<br />

// selling.cpp<br />

#include <br />

#include "selling.h"<br />

#include "food.h"<br />

using namespace std;<br />

Selling::Selling (const Food* food,<br />

const std::string& date,<br />

int itemCount,<br />

double itemPrice)<br />

{<br />

this->food = food;<br />

this->date = date;<br />

this->itemCount = itemCount;<br />

this->itemPrice = itemPrice;<br />

}<br />

double Selling::getProfit () const<br />

{<br />

return itemCount * (itemPrice - food->getPrice());<br />

}<br />

void Selling::print () const<br />

{<br />

cout getName()<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!