How to use dynamic bitset as member data of class?
Hello again, I enjoy to use the dynamic_bitset for the 1 bit correlation of radio interferometor. Very useful. But how to use the dynamic bitsets as the member data of the class? class multi_bitsets{ const boost::dynamic_bitset<> db1(20,1ul); const boost::dynamic_bitset<> db2(20,1ul); this kind of code always gives me the following errors: $ g++ multi_bitset_test00.cpp multi_bitset_test00.cpp:19: error: expected identifier before numeric constant multi_bitset_test00.cpp:19: error: expected `,' or `...' before numeric constant multi_bitset_test00.cpp:19: error: ISO C++ forbids declaration of `parameter' with no type Please let me know how to use the dynamic bitsets as the member data of the class, thank you. fuji
use the initializer list to call their constructors instead:
multi_bitsets() : db1(20,1ul), db2(20,1ul) {
}
On 9/2/05, Fujinobu Takahashi
Hello again,
I enjoy to use the dynamic_bitset for the 1 bit correlation of radio interferometor. Very useful.
But how to use the dynamic bitsets as the member data of the class?
class multi_bitsets{ const boost::dynamic_bitset<> db1(20,1ul); const boost::dynamic_bitset<> db2(20,1ul);
this kind of code always gives me the following errors:
$ g++ multi_bitset_test00.cpp multi_bitset_test00.cpp:19: error: expected identifier before numeric constant multi_bitset_test00.cpp:19: error: expected `,' or `...' before numeric constant multi_bitset_test00.cpp:19: error: ISO C++ forbids declaration of `parameter' with no type
Please let me know how to use the dynamic bitsets as the member data of the class, thank you.
fuji
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Cory Nelson http://www.int64.org
Hello Cory-san, Thank you for your prompt advice for my basic question.
use the initializer list to call their constructors instead:
multi_bitsets() : db1(20,1ul), db2(20,1ul) { }
I tried and the result is as follows:
$ g++ multi_bitset_test00.cpp
multi_bitset_test00.cpp:38: error: expected unqualified-id before ')' token
multi_bitset_test00.cpp:38: error: expected `,' or `;' before ':' token
I am very helpful to gett any comments or solution for the error.
Very thanks,
Fuji
On Sat, 3 Sep 2005 00:17:43 -0700
Cory Nelson
use the initializer list to call their constructors instead:
multi_bitsets() : db1(20,1ul), db2(20,1ul) { }
On 9/2/05, Fujinobu Takahashi
wrote: Hello again,
I enjoy to use the dynamic_bitset for the 1 bit correlation of radio interferometor. Very useful.
But how to use the dynamic bitsets as the member data of the class?
class multi_bitsets{ const boost::dynamic_bitset<> db1(20,1ul); const boost::dynamic_bitset<> db2(20,1ul);
this kind of code always gives me the following errors:
$ g++ multi_bitset_test00.cpp multi_bitset_test00.cpp:19: error: expected identifier before numeric constant multi_bitset_test00.cpp:19: error: expected `,' or `...' before numeric constant multi_bitset_test00.cpp:19: error: ISO C++ forbids declaration of `parameter' with no type
Please let me know how to use the dynamic bitsets as the member data of the class, thank you.
fuji
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Cory Nelson http://www.int64.org
::operator<<(std::basic_ostream<_CharT, _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/ostream.tcc:74: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(s
Hello Cory-san,
Thank you for your prompt advice for my basic question.
I found same thing happens even when I use dynamic bitsets as member
of struct.
My original simple code:
#include <iostream>
#include
On 9/3/05 9:56 AM, "Fujinobu Takahashi"
Hello Cory-san,
Thank you for your prompt advice for my basic question. I found same thing happens even when I use dynamic bitsets as member of struct.
I think you need to review your C++ syntax.
My original simple code: [SNIP] struct multi_bitsets{ dynamic_bitset<> db1(10,1ul); dynamic_bitset<> db2(10,2ul); }; [SNIP] multi_bitset_struct.org.cpp:9: error: expected identifier before numeric constant multi_bitset_struct.org.cpp:9: error: expected `,' or `...' before numeric constant multi_bitset_struct.org.cpp:9: error: ISO C++ forbids declaration of `parameter' with no type multi_bitset_struct.org.cpp:10: error: expected identifier before numeric constant multi_bitset_struct.org.cpp:10: error: expected `,' or `...' before numeric constant multi_bitset_struct.org.cpp:10: error: ISO C++ forbids declaration of `parameter' with no type [SNIP]
You can never initialize members of a struct/class in that fashion. You must use constructors: class multi_bitsets { public: multi_bitsets() : db1(10, 1ul), db2(10, 2ul) {} //... private: dynamic_bitset<> db1, db2; } Or you can initialize a simple struct/class at declaration time: struct test1 { int a, b }; //... int main() { test1 x = { 1, 4 }; //... } I forgot what restrictions, if any, are on that feature. If a class member is of static storage and of a built-in integral type, then you can do: class test2 { static unsigned const xx = 2u; //... } //... unsigned const test2::xx; // You still must do this! (I forgot if it works on "enum" too.)
------------------------------------------------------------------- And modified code with the initializer list suggested by Cory-san: [SNIP] struct multi_bitsets{ dynamic_bitset<> db1; dynamic_bitset<> db2; }; multi_bitsets():db1(10,1ul), db2(10,2ul){} [SNIP] multi_bitset_struct.cpp:14: error: expected unqualified-id before ')' token multi_bitset_struct.cpp:14: error: expected `,' or `;' before ':' token
Not modified enough. All members of a class must be declared in the class body, during or before a definition (if any). You cannot define an impromptu constructor (i.e. with no prior declaration). -- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com
Hello Daryle-san,
I think you need to review your C++ syntax. I sincerely agree and will study C++ again.
I think multi-bitsets class by C++ will be a great breakthrough for radio
interferometry correlation software.
Very thanks your suggestion.
Fuji
On Sat, 03 Sep 2005 18:48:20 -0400
Daryle Walker
On 9/3/05 9:56 AM, "Fujinobu Takahashi"
wrote: Hello Cory-san,
Thank you for your prompt advice for my basic question. I found same thing happens even when I use dynamic bitsets as member of struct.
I think you need to review your C++ syntax.
participants (3)
-
Cory Nelson
-
Daryle Walker
-
Fujinobu Takahashi