Can I call constructor explicitly, without using new, if I already have a memory for object?
class Object1{
char *str;
public:
Object1(c
Based on comments, this only works for Microsoft C++ compilers
Quite simply, without new:
imguistate = (int *)malloc(ImGui::GetInternalStateSize());
memset(imguistate, 0, ImGui::GetInternalStateSize());
((ImGuiState *)imguistate)->ImGuiState::ImGuiState();
This works with any class:
class SomeClass {
public:
SomeClass() {
printf("Called constructor\n");
}
};
int main () {
SomeClass *someclass = new SomeClass;
someclass->SomeClass::SomeClass(); // call constructor again
}