Boost logo

Boost Users :

Subject: Re: [Boost-users] How can I use random library in a class? Can any one with kindness help me?
From: fmingu (fmingu_at_[hidden])
Date: 2010-05-13 05:48:32


ÔÚ2010-05-11 18:05:00£¬"Roman Perepelitsa" <roman.perepelitsa_at_[hidden]> дµÀ£º

2010/5/11 fmingu <fmingu_at_[hidden]>

.................................
class TransferedSignal{
 public:
       TransferedSignal(){
              one(0.0,1.0) ;
              die(rng, one);
        };

Try replacing your constructor with this:
  TransferedSignal() : one(0.0,1.0), die(rng, one) {}

Roman Perepelitsa.
Oh,It works now. But can you tell me the reason about it? Is that a kind of C++ standard to do so? And when I wrote another programs like:

#include <boost/numeric/mtl/mtl.hpp>
using namespace mtl; using namespace mtl::matrix;

 typedef dense2D<double> Matrix;
 typedef dense_vector<double> Vec;

class Used{
public:
    Used(){};
    Used(Matrix inputmatrix, Vec inputvec):matrix(inputmatrix),vec(inputvec),value(111){};
    Matrix getmatrix(){ return matrix;};
    Vec getvec(){return vec;};
    int getvalue(){return value;};
    
protected:
    Matrix matrix;
    Vec vec;
    int value;
};

class Usedchild:public Used{
public:
    Usedchild(Matrix inputmatrix, Vec inputvec):matrix(inputmatrix),vec(inputvec){};

}

the gcc complier told me that:

mainprojectme9.cpp: In constructor 'Usedchild::Usedchild(Matrix, Vec)':
mainprojectme9.cpp:92: error: class 'Usedchild' does not have any field named 'matrix'
mainprojectme9.cpp:92: error: class 'Usedchild' does not have any field named 'vec'

Can anyone tell me why?

Thanks a lot.

 

 



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net