--- Dale Kingston <[EMAIL PROTECTED]> wrote:
> Well I'm kind a new at this c++ thing so I wasn't sure if you can use delete
> just like free and new just like alloce. 

No. In C you would have..

struct foo
{
    int size;
    const char * name;
};


struct foo * new_foo( int a_size, const char * a_size )
{
   struct foo  * f = malloc(sizeof(*f));

   f->name = a_name;
   f->size = a_size;

   return f;
}


And you'd probably create a new foo instance with


struct foo * my_foo = new_foo(15, "bar");

And destroy it with

free(my_foo);


In C++ you would instead have

class foo
{
   public:

      foo(int a_size, std::string a_name): m_size(a_size), m_name(a_name) {}

   private:

      int m_size;
      std::string m_name;
};


And you'd create a new foo instance with:

foo * f = new foo(15, "bar");

And destroy it with

delete f;

Reply via email to