// I prefer to perform forward declaration on myclass, as I do not
// wish to ship "myclass.h" to client
// However, the following code doesn't allow me to do so, as class defination
// is needed in header file.
//
// a.h
#include "myclass.h"
class a {
public:
a();
myclass me;
};
I try to do it another way around. However, I need to use dynamic allocation, which I usually try to avoid.
// a.h
class myclass;
class a {
public:
a();
myclass& me;
};
// But I just wish to avoid new and delete, is it possible?
// a.cpp
#include "myclass.h"
a::a() : me(*(new myclass())) {
}
a::~a() {
delete *myclass;
}
Is it possible to do so, without using any reference or pointer? (Or more precisely, without using new/delete)