Tagged "C++"

Sqlite with C++

This blog post outlines how simple it is to interface with the sqlite3 database platform in a type and memory-safe way using features in modern C++. In order to complie this code, you will need a compiler that supports at least some new features of C++17. Namely: the ability for the compiler to deduce template arguments from constructors. If you want to play with C++17, I suggest grabbing a pre-release snapshot of your favourite compiler.

Simulating Coin Flips in C++

Occasionally I have to generate random numbers in C++, and since C++11 was published the langauge now has a massively powerful, flexible library for generating quality random numbers. The only issue is that for the life of me I cannot remember the API. This would probably not be a problem if I used it more frequently, but anyways, this blog post is a reminder for me of how to generate a uniform distribution.

C++ Friends, Templates, and Friends of Templates

This post is mostly to keep my own memory fresh. It’s been a while since I’ve written any hard-core C++ code, especially code that uses the language to its fullest potential. Let’s assume for some strange reason that you have a class template within another class template. In other words, consider the following code: template <typename T> class outer { int x = 0; public: template <typename U> struct inner { void foo(outer<U> const& o) const { cout << o.

What the heck is C/C++?

I see this all the time in programming forums, websites, etc. My one question is: What the heck language is C/C++? C and C++ are distinct languages that have a similar looking syntax (the same goes for Java, C#, JavaScript, Perl, etc.) And just like the languages I've mentioned in parenthesis, C and C++ also have many syntactic differences. So if they don't have the same syntax, there must be another reason why people conjoin the two languages…