MrPotatoes
June 25th, 2008, 08:56 AM
i have a C++ background but i ended up doing web dev and did some Java but mostly PHP. i found there are a lot of nice things about the languages but overall i wanted performance and power so i came back and have been trying to write myself a small dispatch library as i reteach myself the language.
excuse the redundant use of the this *. it's easier to read imo and i don't forget what member property i'm using.
the question i have right now is about the new operator. i wanted to pass just "new $CLASS_NAME" as a param and then handle it within that function from there. here are some code snippets that i have (it's actually spread out alot so i'll do just the snippets unless asked)
// this is a function within the class:
...
RegisterController("blogs", new BlogsController);
...
// this is the actual function
void RegisterController(string Section, BlogsController * objRegistree)
{
this->Registrar[Section] = objRegistree;
}
// This is the destructor
~ControllerRegistrar()
{
// iterate thru this and delete them all
delete this->Registrar["blogs"];
// this is temporary. didn't write the loop code yet
}
my question is what do i need to make sure i do to not lose that memory if i can do this. it seems to work just file on compile-run but i want to make sure that i am actually deleting the memory. it seems to actually add the class to it
thank you very much for your help
excuse the redundant use of the this *. it's easier to read imo and i don't forget what member property i'm using.
the question i have right now is about the new operator. i wanted to pass just "new $CLASS_NAME" as a param and then handle it within that function from there. here are some code snippets that i have (it's actually spread out alot so i'll do just the snippets unless asked)
// this is a function within the class:
...
RegisterController("blogs", new BlogsController);
...
// this is the actual function
void RegisterController(string Section, BlogsController * objRegistree)
{
this->Registrar[Section] = objRegistree;
}
// This is the destructor
~ControllerRegistrar()
{
// iterate thru this and delete them all
delete this->Registrar["blogs"];
// this is temporary. didn't write the loop code yet
}
my question is what do i need to make sure i do to not lose that memory if i can do this. it seems to work just file on compile-run but i want to make sure that i am actually deleting the memory. it seems to actually add the class to it
thank you very much for your help