<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>syou6162</author_name>
  <author_url>https://blog.hatena.ne.jp/syou6162/</author_url>
  <blog_title>yasuhisa's blog</blog_title>
  <blog_url>https://www.yasuhisay.info/</blog_url>
  <categories>
    <anon>C++</anon>
  </categories>
  <description>明日はもう研究会だというのにC++ではまってなかなか進まないorz(ダメ院生)。staticな変数とかはメモリの上で1つしか存在しないんだと思っていたら、そういうわけではなくソースファイルの中で、ということらしい(キーワード: 翻訳単位)。ちょっと長いが、下の例ではrandomという関数がstaticで定義されていて、グローバルに一つ乱数生成器があるかのように思えるが、bad1とbad2ではそれぞれ乱数生成器が作られてしまっていることが分かる(一列目と三列目の値が一緒)。 /Users/yasuhisa/cpp% g++ -c bad1.cpp; g++ -c bad2.cpp; g++ ba…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fwww.yasuhisay.info%2Fentry%2F20110614%2F1308051369&quot; title=&quot;staticと翻訳単位と乱数生成器 - yasuhisa&amp;#39;s blog&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2011-06-14 20:36:09</published>
  <title>staticと翻訳単位と乱数生成器</title>
  <type>rich</type>
  <url>https://www.yasuhisay.info/entry/20110614/1308051369</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
