cose curiosi con g ++ (forse anche con altri compilatori?):C++ allocazione in pila agisce stranamente
struct Object {
Object() { std::cout << "hey "; }
~Object() { std::cout << "hoy!" << std::endl; }
};
int main(int argc, char* argv[])
{
{
Object myObjectOnTheStack();
}
std::cout << "===========" << std::endl;
{
Object();
}
std::cout << "===========" << std::endl;
{
Object* object = new Object();
delete object;
}
}
Compied con g ++:
===========
hey hoy!
===========
hey hoy!
Il primo tipo di allocazione non costruisce l'oggetto. Cosa mi manca?
Prova 'oggetto myObjectOnTheStack;' cioè senza il '()' – Justicle
@Jerry, grazie ho corretto la terminologia – JaredPar
... "invece * * dichiara una funzione di" ... – Potatoswatter