bitset - STL C++

bitset<N>::to_ulong()

Declaration

unsigned long bitset<N>::to_ulong() const;

Description

This is the member function to_ulong() for the bitset class template. This function returns the unsigned long value equivalent of 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;

	// Output the unsigned long value
	unsigned long ulValue = qBits.to_ulong();
	cout << "The bitset value is " << ulValue << endl;

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

Output

bitset<N>::to_ulong() Output
 

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