mardi 14 avril 2015

C++ can (virtual) private base classes be removed by the compiler?


Vote count:

0




Given the following example:



class A
{
protected:
static void useful_function_without_side_effects() {...}
}

class B : private A
{
// B has no friends :(

public:
void travel_back_in_time() { super_useful_function(); }
}


Question 1: Would it be allowed for the compiler to optimize the base class A out, since this base class can't really affect B or it's run-time behaviour in any way?


Question 2: Would this change if the inheritance would be declared private virtual like this?



class B : private virtual A


asked 32 secs ago







C++ can (virtual) private base classes be removed by the compiler?

Aucun commentaire:

Enregistrer un commentaire