I have used IT++ for half a year, which is a C++ liabrary.
Recently, I got a problem when I try to write the HEADER file for a class,
with a member which is another class object.

Here is part of my code:

class A
{
    private: 
        fixvec fv;
};

fixvec is defined in IT++, actually is renamed from Vec<Fix>
by typedef. fixvec means an array of Fix type data. Vec<> is a more powerful vector template in IT++.
While Fix is a class defined in IT++, to do the fixed-point operation.

When u declare a fixvec object, it only accept parameters like

( int vec_length, fix_factory = DEFAULT_FAC);

.

Look back to my previous class definition. I want to define fv with any parameter I want, not only the DEFAULT_FAC.

The PROBLEM is in class definition, no parameters is allowed.

class A
{
 priveate:
  fixvec fv( length, fix_fac );
};

this cant work;

The only way seems to be my definition.

fixvec fv;

.
Then the default constructor of fixvec will be called, fv will be always with DEFAULT_FAC.

Could anybody help me, please?

I tried static, it can solve this problem, but still not flexible,
neither convenient.

Hope I explained clearly to u guys.
Below is the link for IT++ documentation of Fix and fixvec. u can get more.
http://itpp.sourceforge.net/current/group__fixed.html#gf4093112bbb02b7c82af656adf439499

Write a constructor for A

class A
{
   public:
      A( /* ... */ ) : fv( length, fix_fac ) {}
   private:
     fixvec fv ;
};

Thanks a lot !It works correctly!
Never thought of the initialization list, so foolish.
Always tried to do this in the constructor body.

Thanks again!:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.