J
John
Hi,
I'm having trouble with the code posted below. When I derive my R3
class from X3<PolicyR3>, I do not seem to be able to access any of the
public functions defined at the X3<PolicyR3> level from an object of
type R3. When I compile, the line
b.Set(t);
give the error "no matching function for call to `R3::Set(double[3])'"
What am I doing wrong?
Thanks,
John
// ******************************************************************
class PolicyR3
{
protected:
~PolicyR3() {}
public:
enum { LENGTH = 3 };
enum { DATA_TYPE = 1 };
};
// ******************************************************************
template <class TypePolicy> class X3 : public TypePolicy
{
protected:
using TypePolicy::LENGTH;
using TypePolicy:ATA_TYPE;
enum { VLENGTH = LENGTH * DATA_TYPE };
public:
double m_v[VLENGTH];
X3() : TypePolicy() {}
~X3() {}
void Set(const double *v)
{ for (int i=0; i<VLENGTH; i++) m_v = v; }
};
class R3 : public X3<PolicyR3>
{
public:
R3() : X3<PolicyR3>() {}
/// Set R3 position i to value x
void Set(int i, double x) {m_v = x;}
};
// ******************************************************************
int main ()
{
R3 b;
double t[3] = {1.,2.,3.};
b.Set(1,2.0);
b.Set(t);
return 0;
}
I'm having trouble with the code posted below. When I derive my R3
class from X3<PolicyR3>, I do not seem to be able to access any of the
public functions defined at the X3<PolicyR3> level from an object of
type R3. When I compile, the line
b.Set(t);
give the error "no matching function for call to `R3::Set(double[3])'"
What am I doing wrong?
Thanks,
John
// ******************************************************************
class PolicyR3
{
protected:
~PolicyR3() {}
public:
enum { LENGTH = 3 };
enum { DATA_TYPE = 1 };
};
// ******************************************************************
template <class TypePolicy> class X3 : public TypePolicy
{
protected:
using TypePolicy::LENGTH;
using TypePolicy:ATA_TYPE;
enum { VLENGTH = LENGTH * DATA_TYPE };
public:
double m_v[VLENGTH];
X3() : TypePolicy() {}
~X3() {}
void Set(const double *v)
{ for (int i=0; i<VLENGTH; i++) m_v = v; }
};
class R3 : public X3<PolicyR3>
{
public:
R3() : X3<PolicyR3>() {}
/// Set R3 position i to value x
void Set(int i, double x) {m_v = x;}
};
// ******************************************************************
int main ()
{
R3 b;
double t[3] = {1.,2.,3.};
b.Set(1,2.0);
b.Set(t);
return 0;
}