To initialize or build

I am looking at the code and I see a lot of this:

class Foo
{
public:
  Foo()
  {
    // 'nuffin
  }

  void init()
  {
    // actual construction code
  }
} ;

The only advantage I see is to create Foo without using a pointer, and you want to keep its build code until you can.

Is this a good idea or a bad idea?

+5
source share
10 answers

, , . - , . , , - , , , . , , , , , .

init(), , - , , didInitializationSucceed() .

+3

. , ... ... . , 1 .

 

1 , .

+4

, , , . , , , , (, - , ), , , .

, init(), - , .

+2

, init(). , .

, RAII. RAII , , . , .

+1

, , "Foo" . "Foo" "".

+1

(: ++) , , , , init(). , ?

+1

contructor init, , . , , , , init(). db, contruct($param) $param init($param).

+1

, , , , , - .

, - , , , , /, , . - .

0

, , , - . .

0

, . , , ( - , ..), , , .

, isInitialized(). , .

0

All Articles