abnegator.blogspot.com
reflections: August 2005
http://abnegator.blogspot.com/2005_08_01_archive.html
Tuesday, August 30, 2005. The long wait ends! Meanwhile, cricket is also rocking these days with the Ashes last test becoming a must-watch. England are ahead in the series, 2-1 and they have challenged the Australians, who must have been by now thinking that were unbeatable. It would be a fantastic game to watch. For English Premier League its. Register for free and enjoy all the fun that you can squeeze out of the fantasy football. Cheers. Monday, August 22, 2005. I am not sure. There is a fighter insid...
learningcppisfun.blogspot.com
Learning C++: Accessing static members of a class
http://learningcppisfun.blogspot.com/2009/03/accessing-static-members-of-class.html
Sunday, March 01, 2009. Accessing static members of a class. Static members of a class are not associated with any one particular instance/object of it. They can even be accessed without any instance. The way to refer to them in your code is as shown below:. Static const std: string className;. Static const std: string& getClassName(). Std: cout Test: getClassName();. Std: cout testObject.getClassName();. July 22, 2011 at 8:15 AM. Subscribe to: Post Comments (Atom). New Delhi, Delhi, India. Remove duplic...
learningcppisfun.blogspot.com
Learning C++: Reading file all at once
http://learningcppisfun.blogspot.com/2008/02/reading-file-all-at-once.html
Sunday, February 17, 2008. Reading file all at once. Few times, you would want to read the whole file in one go, not line by line, not by a fixed buffer size. Here's a way to get that done:. Std: fstream ifs("filename.txt");. Std: stringstream oss;. As simple as that. The contents of the file are moved (re-directed) to the stringstream. The same code can be used to make copies of files. You would need to replace the stringstream object with an fstream one though. July 2, 2011 at 8:29 AM. Const in C and C.
learningcppisfun.blogspot.com
Learning C++: Remove duplicates from vector
http://learningcppisfun.blogspot.com/2008/04/remove-duplicates-from-vector.html
Sunday, April 13, 2008. Remove duplicates from vector. Q How do you remove duplicates from a vector? A This is how:. Void removeDuplicates(std: vector T and vec). Std: sort(vec.begin(), vec.end() ;. Vecerase(std: unique(vec.begin(), vec.end() , vec.end() ;. If I needed a container to keep itself populated of only unique values, I would probably choose std: set but then choosing the right container depends on so many other different factors as well. May 16, 2008 at 1:04 PM. CODE- - - -. Vecpush back(30); ...
learningcppisfun.blogspot.com
Learning C++: Copy constructor forms
http://learningcppisfun.blogspot.com/2008/04/copy-constructor-forms.html
Saturday, April 12, 2008. The copy constructor can have both forms(*) as below:. A(const A& rhs);. Both are perfectly valid and it is pretty easy to forget the 'const' for the rhs argument. The compiler accepts it as a perfectly valid syntax thinking that is what your intent was. But the above two are a bit different from each other. The first one rejects to work with/copy from parameters that are not const objects of type A as well as temporaries. So, if you tried something like this:. Const A const a;.
learningcppisfun.blogspot.com
Learning C++: const in C and C++
http://learningcppisfun.blogspot.com/2008/02/const-in-c-and-c.html
Sunday, February 17, 2008. Const in C and C. Globals are usually bad but not always. Consider C code that is to be migrated to C and has a bunch of global constants. As soon as that code is worked upon and is compiled as C , those const globals will cause the compiler to start emitting "undefined reference" or similar errors. This is because of fundamental different between how const is treated in C and C in the context of linkage. Subscribe to: Post Comments (Atom). New Delhi, Delhi, India. Reading file...
learningcppisfun.blogspot.com
Learning C++: Case insensitive string comparison
http://learningcppisfun.blogspot.com/2008/04/case-insensitive-string-comparison.html
Wednesday, April 16, 2008. Case insensitive string comparison. While looking up for case insensitive comparison function, I came across this nice article by Matt Austern : Case Insensitive String Comparison. And decided to try to make a sample that does that. Below is the result, am not sure if it is perfect and has no issues but that is the best I could do. Atleast, better than ignoring the locale completely! Used boost: bind due to buggy bind2nd. Using namespace std;. Using namespace std: tr1;. Std: tr...
learningcppisfun.blogspot.com
Learning C++: Inline specializations and multiple inclusions
http://learningcppisfun.blogspot.com/2009/01/inline-specializations-and-multiple.html
Saturday, January 24, 2009. Inline specializations and multiple inclusions. Recently, I came across a problem being faced by an individual on the forums. He had the code like this:. Std: cout "foo T (" val ") n";. Inline void foo(double val){. Std: cout "foo double (" val ") n";. Something and nothing. What happens is explained below:. Now, with inline functions, we provide the implementation in the header file so as to be visible to the compilation point where they are used. They become inline in th...
learningcppisfun.blogspot.com
Learning C++: Extending enums
http://learningcppisfun.blogspot.com/2010/03/extending-enums.html
Saturday, March 27, 2010. There might come a scenario where you want to include an enum into a another one where the first one is a subset. Struct enum a {. End of enum a = d. Struct enum b : public enum a {. E = end of enum a 1,. Std: printf("enum a: a(%d), b(%d), c(%d), d(%d) n",. Enum b: a, enum b: b, enum b: c, enum b: d);. Std: printf("enum b: e(%d), f(%d), g(%d), h(%d) n",. Enum b: e, enum b: f, enum b: g, enum b: h);. Inheritance to the rescue. :-). Enum b: constant example = enum a: c;. Functors ...
learningcppisfun.blogspot.com
Learning C++: boost::tokenizer and BOOST_FOREACH
http://learningcppisfun.blogspot.com/2008/04/boosttokenizer-and-boostforeach.html
Saturday, April 19, 2008. Boost: tokenizer and BOOST FOREACH. I looked at the documentation. For what all could foreach macro support? The list didn't have boost tokenizer in it, which was expected but it said something that meant, it should work: "The support for STL containers is very general; anything that looks like an STL container counts. If it has nested iterator and const iterator types and begin() and end() member functions, BOOST FOREACH will automatically know how to iterate over it.". Boost: ...