Skip to main content

C++

Change Skype status with QtDbus

Posted in

I will start this post with a small introduction. I'm using pomodoro technique in my work and use a timer for that. The problem I bumped into was that there is no cross platform pomodoro timer.

Template operator specialization

Posted in

Remember I had a problem with using a specialization for the template operator in a template class here?

Having fun with Lazy Load

Posted in

Here is the problem I had to solve recently. I have objects, whose describing information is stored in a database.

bitset vs vector

Posted in

It is a very popular question what are the differences between bitset and vector. Here they are (probably, these are the main differences, but not all of them, I guess)

Pure virtual method called

Posted in

I managed to make a pure virtual method to be called. I'm not kidding, I'm serious and I mean it.

Trivial do-while loop

Posted in

You might have seen such code.

do {
// ...
} while (0);

Me personally have seen it a lot and never knew what was this for.

There 2 reasons for doing this:

Problem #2

Posted in

static int a = 0, b = 3;
 
int change_a() { return ++a; }
int change_b(int x) { return b+=x; }
 
void func(int x)
{
    static int aa = change_a();
    static int bb = change_b(x);
}

Problem #1

Posted in

struct S {
    static int i;
 
    S() { ++i; }
    S(const S&) { ++i; }
};
 
int S::i = 0;
 
int main() {
    S v(S());
 
    return S::i;
}

Overloading << for a custom class

Posted in

Q: Why overload << operator outside your own class and then make it its friend? Why not make it a member?

mutable VS const

Posted in

class A {
  mutable int value1;
 
  public:
     int getValue1() const;
};
 
...
 
int A::getValue1() const
{
  return ++vaue1;
}

Syndicate content