-
Notifications
You must be signed in to change notification settings - Fork 1
/
TGridCell.cpp
50 lines (40 loc) · 843 Bytes
/
TGridCell.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* File TGridCell.cpp
*/
#include "TGridCell.h"
#include "dws_random.h"
#define RESPROUT_AGE 4
//ctors
TGridCell::TGridCell()
:
_plant(0)
{}
TGridCell::TGridCell(const TGridCell& copy)
{
if (_plant==0) _plant = new TGenotype;
*_plant = *(copy._plant);
}
TGridCell::~TGridCell()
{
delete _plant;
}
//
TGridCell& TGridCell::operator=(const TGridCell& source)
{
if(&source == this) return *this;
if (_plant==0) _plant = new TGenotype;
*_plant = *(source._plant);
return *this;
}
/////////////////////////////////////////////////////////////////
// Friend fxns
/////////////////////////////////////////////////////////////////
std::ostream& operator<<(std::ostream& os, const TGridCell& g)
{
os << *g._plant << '\n';
return os;
}
std::istream& operator>>(std::istream& is, TGridCell& g)
{
is >> *g._plant;
return is;
}