Categories
Archives
Tag Archives: c++
Java needs operator overloading
I like Java but I can’t understand why it still doesn’t have operator overloading. Everyday operator overloading Every Java object has two (and more) methods: String toString(): Returns a string representation of the object. boolean equals(Object obj): Indicates whether some … Continue reading
Be careful when using post-increment++
Have a look at the following code to see a sample (dangerous) use of the post increment operator (i++). #include <iostream> class A { public: A() { i=0; f(i++); } void f(int p) { std::cout << "p=" << p … Continue reading
String to int argc, char** argv
I’ve recently needed a simple command line string parser, which does some basic things. Nothing special. It’s not 100% compatible with Linux or Windows, but should work for most cases. What it does: parsing std::string to std::vector parsing std::string to … Continue reading