background preloader

Languages

Facebook Twitter

PythonMonk - Interactive Python tutorials. 10 Things C++ Developers Learning C# Should Know. After taking a lot of time with C# fundamentals, I decided to go down a different road this week and talk about some of the differences in C# that can be troublesome to people who are used to C++ development but are learning C#. My first post on this blog months ago was just a simple piece on how I divorced C++ as my first-love language (here). This is not to say that C++ is not still a valuable language, in fact as far as object-oriented languages go C++ is still king of performance. That said, C++ has a lot of quirks and idiosyncrasies due to its age and backward-compatibility with C that have caused it to take a back seat to C# and Java for business programming where time-to-market and maintainability are more important than having the absolute best performance. C# especially has made huge inroads into the business development market because it offers a lot of the power of C++ without a lot of the danger. 1.

Garbage Collection is non-deterministic 2. 3. 4. 1: class Shape 3: public: 5.

Web design and rules

Android. Frameworks and tools. Esoteric languages. Welcome to Scriptar.com. Teejeejee: Playing with C++0x -- lambdas. C++0x has a workload of new features[2]... Today I'm having a look at lambdas. Lambdas are available in g++-4.5, for now only available in experimental. What are lambdas? Closures are a very powerful tool that are being retrofitted in many languages (for instance Java). Enough for theory, let's have a look at this new beast. How do they look like? [](int i) { return i + 1; }; This is the increment lambda.

How to read this? Using a lambda To use it add arguments, for instance: [](int i) { return i + 1; }(0); would compute the value 1. Storing a lambda The type of a lambda is automatically deduced. Auto inc = [](int i) { return i + 1; }; std::cout << inc(0) << std::endl; Notice that calling a named lambda is not different from calling a function. Auto mult = [](int x, double y) -> double { return x * y; }; Capturing environment You can use lambdas to capture outter environment. Void f() { int x = 5; [](int w) { return w + x; }(0); } void f() { int x = 5; [=](int w) { return w + x; }(0); } Yes, mutable. iOS Dev Center. Getting Started with MTJ. STL Containers. Library Standard Containers A container is a holder object that stores a collection of other objects (its elements).

They are implemented as class templates, which allows a great flexibility in the types supported as elements. The container manages the storage space for its elements and provides member functions to access them, either directly or through iterators (reference objects with similar properties to pointers). Containers replicate structures very commonly used in programming: dynamic arrays (vector), queues (queue), stacks (stack), heaps (priority_queue), linked lists (list), trees (set), associative arrays (map)...

Many containers have several member functions in common, and share functionalities. The decision of which type of container to use for a specific need does not generally depend only on the functionality offered by the container, but also on the efficiency of some of its members (complexity). Stack, queue and priority_queue are implemented as container adaptors. Array. Learn C++