Search raisama.net:

Eduardo Habkost raisama.net

diary / 2005 / July

Qui 28 Jul 2005
16h42min
permalink

Junte um tradutor incompetente com um jornalista incompetente. O que você tem?

http://noticias.uol.com.br/bbc/2005/07/28/ult2363u3936.jhtm

“os estudantes liberaram a receita sob a Licença Criativa de Bens Comuns.”.

Vamos todos liberar os nossos trabalhos sob a Licença Criativa de Bens Comuns. Porque as licenças precisam de mais criatividade.

Comente!
Categoria: Casa, Em Português
12h41min
permalink

umount /home

Estamos em processo de mudança. Ontem levamos um terço da mudança para a lata de goiabada. O fogão e a máquina de lavar roupas, e várias caixas cheias de coisas.

E a surpresa foi acharmos, após medir o elevador, que precisaríamos levar a cama de escada. Medi a cama hoje, e para nosso alívio ela tem a medida exata para caber na diagonal dentro do elevador. Então não teremos a aventura de subir um box de casal pela escada, 12 andares acima.

Sexta-feira, estaremos definitivamente no cafofo novo. Aguardem os próximos relatos.

2 comentários
Seg 25 Jul 2005
19h21min
permalink

Funny behaviour of C++

I’ve just discovered an unexpected (but interesting) property of how C++ handles constructors and virtual methods. It took some time to figure out what was happening.

Who can guess correctly what this piece of code below will print? (without compiling and running it, of course)

#include <iostream>
using namespace std;

class A
{
public:
        virtual void v(int x) { cout < < "A::v" << x << endl; }
        A(int x) { v(x); }
};

class B : public A
{
public:
        B(int x) : A(x) { }
        virtual void v(int x) { cout << "B::v" << x << endl; }
};

int main()
{
        B b(1);
        b.v(3);
        ((A*)&b)->v(4);
        ((A)b).v(5);
        ((A&)b).v(6);
        return 0;
}

Update: As there were no comments, here is the solution:

A::v1
B::v3
B::v4
A::v5
B::v6

The most interesting feature, that hit me yesterday was what caused A::v1 to be shown. If we call a virtual method of A during the A constructor, the B virtual methods won’t be called. Initially this doesn’t make sense to me, but it seems that there is a some rule that makes a non-static method of a class C never be called before the C constructor is called. Considering this rule, the behaviour starts to make sense (althought it isn’t too intuitive, anyway).

BTW, if someone has a suggestion of a solution to work around this feature (I want to call a certain virtual method of A automatically when a descendant-of-A (B, for example) object is created), without having to expose a init() method to the users of descendant-of-A, it will be welcome.

4 comentários
16h08min
permalink

Fighting spam

Fighting spam efficiently.

I confess I wouldn’t worry too much if this tecnhique becomes popular.

Comente!
16h01min
permalink

Combatendo o spam

Técnicas eficientes para combater o spam.

Eu não iria ficar muito triste se a moda pegasse.

Comente!
Hosting service by Dreamhost