Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 5-12-2016.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- class Obdlznik
- {
- protected: int a,b;
- public: Obdlznik();
- Obdlznik(int a, int b);
- int obsah();
- //void kresli();
- };
- Obdlznik::Obdlznik()
- {
- a = 0;
- b = 0;
- }
- Obdlznik::Obdlznik(int a, int b)
- {
- this->a=a;
- this->b=b;
- }
- int Obdlznik::obsah() {
- int vypocet;
- vypocet = a * b;
- return vypocet;
- }
- class Stvorec : public Obdlznik {
- public: Stvorec();
- Stvorec(int a);
- int obsah();
- //void kresli();
- };
- Stvorec::Stvorec() {
- a = 0;
- b = 0;
- }
- Stvorec::Stvorec(int a) : Obdlznik(a,a){
- cout << "Ciselko: " << a << endl;
- }
- int Stvorec::obsah() {
- return a*a;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- Obdlznik o(2,5);
- cout << "Obsah je: " << o.obsah() << endl;
- Stvorec s(2);
- cout << "Obsah stvorca je: " << s.obsah() << endl;
- getchar();
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement