bitset - STL C++

bitset<N>::size()

Declaration

size_t bitset<N>::size() const;

Description

This is the member function size() for the bitset class template. This function returns the number of bits in the bitset.

Header Include

#include <bitset>

Example

#include <bitset>
#include <iostream>

int main()
{
	using namespace std;

	// Create a bitset
	bitset<4> qBits(5);
	cout << "bitset<4> : " << qBits << endl;

	// Get the number of bits in the bitset
	cout << "Bits in bitset = " << qBits.size() << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

bitset<N>::size() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.