Click here to Skip to main content
16,011,805 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: another Important Question Pin
Ben Burnett20-Jun-01 10:14
Ben Burnett20-Jun-01 10:14 
GeneralFile Sharing Violation Pin
Fady Elias20-Jun-01 9:48
Fady Elias20-Jun-01 9:48 
GeneralC++ Refcounting design Pin
Jim Crafton20-Jun-01 9:12
Jim Crafton20-Jun-01 9:12 
GeneralRe: C++ Refcounting design Pin
Tomasz Sowinski20-Jun-01 9:25
Tomasz Sowinski20-Jun-01 9:25 
GeneralRe: C++ Refcounting design Pin
Jim Crafton20-Jun-01 12:07
Jim Crafton20-Jun-01 12:07 
GeneralRe: C++ Refcounting design Pin
Tomasz Sowinski20-Jun-01 23:59
Tomasz Sowinski20-Jun-01 23:59 
GeneralRe: C++ Refcounting design Pin
Jim Crafton21-Jun-01 4:38
Jim Crafton21-Jun-01 4:38 
GeneralRe: C++ Refcounting design Pin
Tomasz Sowinski21-Jun-01 1:12
Tomasz Sowinski21-Jun-01 1:12 
> no - good point, I suppose it should be protected

So it doesn't have to be virtual... Note that you're always dealing with object of type Foo in Foo::create:

static Foo* create( int count )
{
Foo* result = new Foo( count );
result->init(); //calls Foo::init even if init isn't virtual
return result;
}

In fact, if you don't have two or more versions of Foo::create, you could place all init functionality inside create.

Personally, I'd move the parameters from the constructor to non-virtual init:
static Foo* create( int count )
{
Foo* result = new Foo();
result->init(count);
return result;
}

The only thing that constructor does in this scenario is initializing vtable pointer (this of course is done automatically for you). 'Real' init would be performed in init() itself.


Tomasz Sowinski -- http://www.shooltz.com.pl
GeneralRe: C++ Refcounting design Pin
Jim Crafton21-Jun-01 4:35
Jim Crafton21-Jun-01 4:35 
GeneralRe: C++ Refcounting design Pin
Tomasz Sowinski21-Jun-01 4:42
Tomasz Sowinski21-Jun-01 4:42 
GeneralRe: C++ Refcounting design Pin
Jim Crafton21-Jun-01 5:55
Jim Crafton21-Jun-01 5:55 
GeneralRe: C++ Refcounting design Pin
Tomasz Sowinski21-Jun-01 6:21
Tomasz Sowinski21-Jun-01 6:21 
GeneralRe: C++ Refcounting design Pin
Jim Crafton21-Jun-01 6:40
Jim Crafton21-Jun-01 6:40 
GeneralRe: C++ Refcounting design Pin
Tomasz Sowinski21-Jun-01 7:05
Tomasz Sowinski21-Jun-01 7:05 
GeneralRe: C++ Refcounting design Pin
Jim Crafton21-Jun-01 7:32
Jim Crafton21-Jun-01 7:32 
GeneralRe: C++ Refcounting design Pin
20-Jun-01 15:33
suss20-Jun-01 15:33 
GeneralRe: C++ Refcounting design Pin
Jim Crafton20-Jun-01 16:49
Jim Crafton20-Jun-01 16:49 
GeneralRe: C++ Refcounting design Pin
Jonathan Gilligan21-Jun-01 8:43
Jonathan Gilligan21-Jun-01 8:43 
GeneralRe: C++ Refcounting design Pin
Gerald Schwab21-Jun-01 15:31
Gerald Schwab21-Jun-01 15:31 
GeneralI have alittle problem(so I hope) in my code . Please try help me !!!!! Pin
20-Jun-01 9:05
suss20-Jun-01 9:05 
GeneralWhy no one answer me ??? Please !!! it is urgent !!! Pin
20-Jun-01 9:49
suss20-Jun-01 9:49 
GeneralRe: Why no one answer me ??? Please !!! it is urgent !!! Pin
20-Jun-01 10:06
suss20-Jun-01 10:06 
GeneralRe: I have alittle problem(so I hope) in my code . Please try help me !!!!! Pin
Ben Burnett20-Jun-01 10:08
Ben Burnett20-Jun-01 10:08 
GeneralForm Resizing in SDI app. Pin
Fady Elias20-Jun-01 7:53
Fady Elias20-Jun-01 7:53 
QuestionMultiple application icons? Pin
Chris Losinger20-Jun-01 7:39
professionalChris Losinger20-Jun-01 7:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.