/* The following code example is taken from the book * "The C++ Standard Library – A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in all copies. * This software is provided "as is" without express or implied * warranty, and with no claim as to its suitability for any purpose. */ #include <bitset> #include <iostream> using namespace std; int main() { /* enumeration type for the bits * – each bit represents a color */ enum Color { red, yellow, green, blue, white, black, //…, numColors }; // create bitset for all bits/colors bitset<numColors> usedColors; // set bits for two colors usedColors.set(red); usedColors.set(blue); // print some bitset data cout << "bitfield of used colors: " << usedColors << endl; cout << "number of used colors: " << usedColors.count() << endl; cout << "bitfield of unused colors: " << ~usedColors << endl; // if any color is used if (usedColors.any()) { // loop over all colors for (int c = 0; c < numColors; ++c) { // if the actual color is used if (usedColors[(Color)c]) { //… } } } } /* bitfield of used colors: 001001 number of used colors: 2 bitfield of unused colors: 110110 */ Note: Brought from our …
Category: FromSitesTree.com
May 15
Ajax: Basic Operations Code #Programming Code Examples #Ajax #Ajax
Get a handle to XMLHttpRequest object function getAjaxObject(){ var ajaxObject = false; if (window.XMLHttpRequest){ ajaxObject = new XMLHttpRequest(); }else if (window.ActiveXObject) { try{ ajaxObject = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ ajaxObject = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ ajaxObject = false; } } } return ajaxObject; } use of onreadystatechange if (ajaxObject){ //takeAction – reference to a function ajaxObject.onreadystatechange …
May 15
Review: Overview of Project Management #PMP – Project Management
Overview of Project Management [Source Internet] What is a project? A project is an activity that using plans and processes creates a product, a service, or a result. A product is a physical product like a TV, a service is like the Internet, a website; result [analytical model, proof of something] is the knowledge based …
May 15
Some Topics on Project Communication Management #PMP – Project Management
Some Topics on Project Communication Management For bigger projects communication also needs to be preplanned and executed effectively. Though based on circumstances the plan may be reviewed and changed. Overview Project communication can be very tricky and political Deals with Compiling, Sending, Storing, distributing and managing project record Handles four areas:What to communicate, to whom, …
May 15
valarray with double value inside #Programming Code Examples #C++ #Valarray
/* The following code example is taken from the book * "The C++ Standard Library – A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in …
May 15
Sort objects stored in deque #Programming Code Examples #C++ #Std Algorithms
/* The following code example is taken from the book * "The C++ Standard Library – A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in …
May 15
Use sorting criterion in sort function #Programming Code Examples #C++ #Std Algorithms
/* The following code example is taken from the book * "The C++ Standard Library – A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in …
May 15
A Simple C++ Program #Programming Code Examples #C++ #File
#include <iostream> #include <fstream> using namespace std; int main() { ifstream in("test", ios::in | ios::binary); if(!in) { cout << "Cannot open input file.n"; return 1; } double num; char str[80]; in.read((char *) &num, sizeof(double)); in.read(str, 14); str[14] = ”; // null terminate str cout << num << ‘ ‘ << str; in.close(); return 0; } …
May 15
Read file content #Programming Code Examples #C++ #File
#include <iostream> #include <fstream> using namespace std; int main() { ifstream in("test", ios::in | ios::binary); if(!in) { cout << "Cannot open input file.n"; return 1; } double num; char str[80]; in.read((char *) &num, sizeof(double)); in.read(str, 14); str[14] = ”; // null terminate str cout << num << ‘ ‘ << str; in.close(); return 0; } …
May 15
Print minimum, maximum, and sum of the valarray #Programming Code Examples #C++ #Valarray
/* The following code example is taken from the book * "The C++ Standard Library – A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in …
