What are the basic rules and idioms for operator overloading in C++? Note: The answers were given in a specific order, but since many users sort an
Continue ReadingC++: What are the differences between a pointer variable and a reference variable in C++?
I know references are syntactic sugar, so code is easier to read and write. But what are the differences? Summary from answers and links bel
Continue ReadingC++ Questions
[pt_view id="6491efea00"]
Continue ReadingC++: Binary Search Tree Verification
struct TreeNode { int data; TreeNode *left; TreeNode *right; }; bool isBST(TreeNode *node, int minData, int maxData) { if(node == NULL
Continue ReadingC++: Split a string in C++
What’s the most elegant way to split a string in C++? The string can be assumed to be composed of words separated by whitespace. (Note that I’m
Continue ReadingC++: Longest Common Subsequence
#include <algorithm> #include <string> #include <vector> #include <stdio.h> #include <string.h> // See http
Continue ReadingWhy doesn’t GCC optimize a*a*a*a*a*a to (a*a*a)*(a*a*a)?
I am doing some numerical optimization on a scientific application. One thing I noticed is that GCC will optimize the call pow(a,2) by compiling it in
Continue ReadingC++: Bubble Sort
#include <algorithm> template<typename Iterator> void bubbleSort(Iterator first, Iterator last) { Iterator i, j; for (i = fir
Continue ReadingC++: Merge Sort
#include <iostream> using namespace std; void merge(int a[], const int low, const int mid, const int high) { // Variables declarati
Continue ReadingRead/convert an InputStream to a String
If you have java.io.InputStream object, how should you process that object and produce a String? Suppose I have an InputStream that contains te
Continue Reading




