Array of bitsets

Good day,

I am working on DES encryption (it's a school project), and I need to use an array of bitsets. How do I go about doing this?

I've tried:
bitset<64> subkeys[16];

But when I try to access f.e. 'subkeys[1]' the compiler thinks I mean bit° 1 in a (non-array) variable 'subkeys'.

I am also not able to pass a pointer to a bitset from one function to another. I assume I'm doing something wrong, but I'd like to know if it's possible in the first place.


Google wasn't able to bring me any closer to a solution. I hope you guys can!


Thanks in advance,
Mr Hat
#include <iostream>
#include <bitset>

using namespace std;

int main(void)
{
bitset<64> subkeys[16];

cout << subkeys[1] << endl;

return 0;
}

[root@admin shm]# c++ bitset.cpp && ./a.out
0000000000000000000000000000000000000000000000000000000000000000
[root@admin shm]# c++ --version
c++ (GCC) 3.4.5
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@admin shm]#

seems my compiler works fine on it. throw your compiler to garbage can plz.
Thanks for the fast reply!


The arrays do seem to work after I re-opened the project (weird, I use VS 2010 ultimate).

However, I am still not able to pass them to functions using pointers. I can pass a single bitset, but not an array containing multiple bitsets.



Thanks for the help so far, chinalinux!
closed account (1vRz3TCk)
Try passing it by reference.
Topic archived. No new replies allowed.