improve coherency between UniformVariable and RandomVariable, explain why the extra overload is necessary.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 25 Feb 2009 13:10:22 +0100
changeset 4242 3d4788bd1ddd
parent 4241 c35796bc0b4b
child 4243 d84e644c9692
improve coherency between UniformVariable and RandomVariable, explain why the extra overload is necessary.
src/core/random-variable.cc
src/core/random-variable.h
--- a/src/core/random-variable.cc	Wed Feb 25 11:00:50 2009 +0100
+++ b/src/core/random-variable.cc	Wed Feb 25 13:10:22 2009 +0100
@@ -264,9 +264,9 @@
   : RandomVariable (UniformVariableImpl (s, l))
 {}
 
-double UniformVariable::GetValue()
+double UniformVariable::GetValue(void) const
 {
-  return Peek()->GetValue();
+  return this->RandomVariable::GetValue ();
 }
 
 double UniformVariable::GetValue(double s, double l)
--- a/src/core/random-variable.h	Wed Feb 25 11:00:50 2009 +0100
+++ b/src/core/random-variable.h	Wed Feb 25 13:10:22 2009 +0100
@@ -176,10 +176,15 @@
   UniformVariable(double s, double l);
 
   /**
-  * \brief Returns a random double with the specified range given by constructor
+  * \brief call RandomVariable::GetValue
   * \return A floating point random value
+  *
+  * Note: we have to re-implement this method here because the method is 
+  * overloaded below for the two-argument variant and the c++ name resolution
+  * rules don't work well with overloads split between parent and child 
+  * classes.
   */
-  double GetValue();
+  double GetValue (void) const;
   
   /**
   * \brief Returns a random double with the specified range