Tag Archives: c++

I Shouldn’t Be Allowed to Use a C++ Compiler

class mesh_cell
{
double _x, _v, _P, _rho, _q, _e;

public:

// Defines that automatically write get/set accessors for me if I provide the variable names.
// Evil? Saves me writing boilerplate though!
#define var(i) double& i() { return _##i; }
#define get_var(i) const double& get_##i() const { return _##i; }
#define set_var(i) void set_##i(const double& var) { _##i = var; }
#define gs_var(i) var(i) get_var(i) set_var(i)

gs_var(x)
gs_var(v)
gs_var(P)
gs_var(rho)
gs_var(q)
gs_var(e)

mesh_cell()
{
}
};

I need help.