Intro_Class_Area
form.cpp
Go to the documentation of this file.
1
#include "
form.h
"
2
3
#include <iostream>
4
using namespace
std;
5
6
// keep the CLANG compiler silent (it is right!)
7
// https://stackoverflow.com/questions/28786473/clang-no-out-of-line-virtual-method-definitions-pure-abstract-c-class
8
Form::~Form
() {}
9
10
float
Quadrat::area
()
const
11
{
12
return
_edge * _edge;
13
}
14
15
float
Circle::area
()
const
16
{
17
return
static_cast<
float
>
(M_PI) * _radius * _radius;
18
}
19
20
bool
operator<
(
const
Form
&a,
const
Form
&b)
21
{
22
return
a.
area
() < b.
area
();
23
}
24
25
bool
kleiner
(
const
Form
*a,
const
Form
*b)
26
{
27
return
a->
area
() < b->
area
();
// uses operator<(const Form &a, const Form &b)
28
}
29
30
// Output-Operator : Here we benefit from polymorphism
31
ostream &
operator<<
(ostream &s,
const
Form
&rhs)
32
{
33
s << rhs.
classname
() <<
" with centre "
;
34
s <<
"("
<< rhs.
GetX
() <<
","
<< rhs.
GetY
() <<
")"
;
35
s <<
" has an area of "
<< rhs.
area
();
36
return
s;
37
}
Circle::area
float area() const override
Definition:
form.cpp:15
Form
Definition:
form.h:10
Form::area
virtual float area() const =0
Form::GetX
float GetX() const
Definition:
form.h:17
Form::GetY
float GetY() const
Definition:
form.h:21
Form::classname
virtual std::string classname() const
Definition:
form.h:26
Form::~Form
virtual ~Form()
Definition:
form.cpp:8
Quadrat::area
float area() const override
Definition:
form.cpp:10
kleiner
bool kleiner(const Form *a, const Form *b)
Definition:
form.cpp:25
operator<
bool operator<(const Form &a, const Form &b)
Definition:
form.cpp:20
operator<<
ostream & operator<<(ostream &s, const Form &rhs)
Definition:
form.cpp:31
form.h
Generated on Mon Dec 11 2023 15:48:37 for Intro_Class_Area by
1.9.1