Originally posted by Dave Evans
In order to be able to store an input, cin must know the address of the target. A bit field does not have an address.
hmm. Maybe incorrect but, it works fine as it's written in my compiler.
Code:
#include <iostream>
#include <conio.h>
using namespace std;
struct MyBools
{
unsigned short b1, b2, b3, b4, b5, b6, b7, b8, b9, b10;
};
int main()
{
MyBools bOne = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
cout << "Enter in 10 1's or 0's: ";
cin >> bOne.b1 >> bOne.b2 >> bOne.b3 >> bOne.b4 >> bOne.b5 >> bOne.b6
>> bOne.b7 >> bOne.b8 >> bOne.b9 >> bOne.b10;
cout << bOne.b1 << bOne.b2 << bOne.b3 << bOne.b4 << bOne.b5 << bOne.b6
<< bOne.b7 << bOne.b8 << bOne.b9 << bOne.b10;
getch();
return 0;
}
edit: typo