close

http://www.parashift.com/c++-faq-lite/static-init-order-on-first-use.html

 

// File x.cpp

#include "Fred.h"

Fred& x()
{
  static Fred* ans = new Fred();
  return *ans;
}

// File Barney.cpp
#include "Barney.h"

Barney::Barney()
{
  ...
  x().goBowling();
  ...
}
arrow
arrow
    全站熱搜

    hedgezzz 發表在 痞客邦 留言(0) 人氣()