Error: expected type-specifier before ‘ClassName’

For future people struggling with a similar problem, the situation is that the compiler simply cannot find the type you are using (even if your Intelisense can find it). This can be caused in many ways: You forgot to #include the header that defines it. Your inclusion guards (#ifndef BLAH_H) are defective (your #ifndef BLAH_H doesn’t match your #define BALH_H due … Read more

SQL Server Insert if not exists

instead of below Code replace with Updated : (thanks to @Marc Durdin for pointing) Note that under high load, this will still sometimes fail, because a second connection can pass the IF NOT EXISTS test before the first connection executes the INSERT, i.e. a race condition. See stackoverflow.com/a/3791506/1836776 for a good answer on why even wrapping in a … Read more

Playing mp3 song on python

Try this. It’s simplistic, but probably not the best method. Please note that pygame’s support for MP3 is limited. Also, as pointed out by Samy Bencherif, there won’t be any silly pygame window popup when you run the above code. Installation is simple – Update: Above code will only play the music if ran interactively, since the play() call will execute instantaneously … Read more

Proper way to wait for one function to finish before continuing?

One way to deal with asynchronous work like this is to use a callback function, eg: As per @Janaka Pushpakumara’s suggestion, you can now use arrow functions to achieve the same thing. For example: firstFunction(() => console.log(‘huzzah, I\’m done!’)) Update: I answered this quite some time ago, and really want to update it. While callbacks are … Read more

What is the difference between Integer and int in Java?

int is a primitive type. Variables of type int store the actual binary value for the integer you want to represent. int.parseInt(“1”) doesn’t make sense because int is not a class and therefore doesn’t have any methods. Integer is a class, no different from any other in the Java language. Variables of type Integer store references to Integer objects, just as with any other reference (object) type. Integer.parseInt(“1”) is a call to the … Read more