Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > private member ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 45825 of 45888
Post > Topic >>

private member variables

by wiskey5alpha <wiskey5Alpha@[EMAIL PROTECTED] > May 9, 2008 at 07:50 AM

Hello all.

I have a design question.

assuming we have
class Bar {...}   // body omitted for clarity

class Foo
{
     // should Bar be implemented as a pointer or not here ?
    Bar *m_bar;  // OPTION 1
   // or
   Bar m_bar;   // OPTION 2

.... // body omitted for clarity

Foo::Foo()
    // OPTION 1
    m_bar = new Bar;
    m_bar.setID(1);
    // or
    m_bar.setID(1);

I have seen both of these methods used, so I am wondering if there
is any memory or speed differences between the two ?




 6 Posts in Topic:
private member variables
wiskey5alpha <wiskey5A  2008-05-09 07:50:48 
Re: private member variables
James Kanze <james.kan  2008-05-09 08:07:07 
Re: private member variables
"3DCoderGuy" &l  2008-05-09 15:35:24 
Re: private member variables
"Jim Langston"   2008-05-09 09:00:57 
Re: private member variables
wiskey5alpha <wiskey5A  2008-05-09 10:15:03 
Re: private member variables
mlimber <mlimber@[EMAI  2008-05-09 10:35:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 18:29:10 CDT 2008.