ECF 1.5
Sub.h
1#ifndef Sub_h
2#define Sub_h
3#include "Primitive.h"
4
5namespace Tree {
6namespace Primitives {
7
12template <class T>
13class SubT : public Primitive
14{
15public:
16 SubT(void);
17 void execute(void* result, Tree& tree);
18 ~SubT(void);
19};
20typedef SubT<double> Sub;
21
22template <class T>
23SubT<T>::SubT(void)
24{
25 nArguments_ = 2;
26 name_ = "-";
27 complementName_ = "+";
28}
29
30
31template <class T>
32SubT<T>::~SubT(void)
33{
34}
35
36template <class T>
37void SubT<T>::execute(void* result, Tree& tree)
38{
39 T prvi, drugi;
40 T& res = *(T*)result;
41 getNextArgument(&prvi, tree);
42 getNextArgument(&drugi, tree);
43 res = prvi - drugi;
44}
45
46}
47}
48
49#endif
Base primitive class (Tree genotype).
Definition: Primitive.h:37
Sub function primitive (Tree genotype)
Definition: Sub.h:14
void execute(void *result, Tree &tree)
Execute the primitive.
Definition: Sub.h:37
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29