Boost logo

Boost Users :

From: David Klein (dave_chp_at_[hidden])
Date: 2007-07-21 12:00:22


GQ Chen wrote:
> Hi,
>
> I have some troubles in compiling the following simple code,
> tboost.hpp, tboost.cpp
> The problem is always from the declaration of
> array_type A(boost::extents[2000000][1]);
>
> in the header file.
>
> Error message from compiling,
>
> In file included from tboost.cpp:2:
> tboost.h:14: error: `extents' has not been declared
> boost.h:14: error: ISO C++ forbids declaration of `parameter' with no type
>
>
> If I define
> array_type A(boost::extents[2000000][1]);
> in the source code tboost.cpp, it will compile successfully.
>
> Could anyone help me to solve it? Thanks a lot,
>
> gq
>
>
>
>
> tboost.hpp
>
>
> #include <cassert>
> #include <stdio.h>
> #include <iostream>
> #include "boost/multi_array.hpp"
>
> typedef boost::multi_array<double, 2> array_type;
>
> class tboost
> {
> public:
> tboost(){};
> ~tboost(){};
> public:
> array_type A(boost::extents[2000000][1]);
> };
>
> #endif
>
>
> tboost.cpp
>
> #include "tboost.h"
> int main () {
> char c =getchar();
> return 0;
> }
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
Hi,

use the constructors initializer list...

class tboost
{
public:
    array_type A;
   
    tboost( void ) :
        A(boost::extents[2000000][1])
    {
    }
};

--
HTH,
dave

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