<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
 <channel>
  <atom:link href="https://smaugmuds.afkmods.com/index.php?a=rssfeed&amp;t=1121" rel="self" type="application/rss+xml" />
  <title>SmaugMuds - Topic: A nice fat stumper for you all</title>
  <link>https://smaugmuds.afkmods.com/index.php?a=rssfeed&amp;t=1121</link>
  <description>The largest Smaug community resource site. - </description>
  <language>en</language>
  <generator>SmaugMuds</generator>
  <ttl>60</ttl>
  <item>
   <title>A nice fat stumper for you all</title>
   <link>https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15875#p15875</link>
   <description>You&#039;re right, I should have made it more clear that when I said &#039;member object&#039;, the word &#039;object&#039; was very deliberately chosen. :wink: That said, some container types over primitives like int etc. will call the constructor (initializer might be a more appropriate term) when they find that they need to insert objects, e.g. to fill up space in a vector if you inserted past the last element. But that&#039;s different from new&#039;s behavior.</description>
   <guid isPermaLink="true">https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15875#p15875</guid>
   <pubDate>Fri, 5 Sep 2008 10:48:20 CDT</pubDate>
   <category>Coding</category>
   <author>nobody@example.com (David Haley)</author>
  </item>
  <item>
   <title>A nice fat stumper for you all</title>
   <link>https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15874#p15874</link>
   <description>It&#039;ll call constructors for any non-POD type, but it won&#039;t do it for basic types. So your ints and so on will still be uninitialised.</description>
   <guid isPermaLink="true">https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15874#p15874</guid>
   <pubDate>Fri, 5 Sep 2008 05:54:34 CDT</pubDate>
   <category>Coding</category>
   <author>nobody@example.com (Kylotan)</author>
  </item>
  <item>
   <title>A nice fat stumper for you all</title>
   <link>https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15406#p15406</link>
   <description>Well, actually, when you call &#039;new&#039;, it also calls the constructor of every member object of the object. For instance, if you have a struct that contains string objects, creating one with &#039;new&#039; will initialize those string objects correctly. That is the default behavior. Note that this does not apply to pointers. As a minor correction to my remark from a few months ago, the constructor is also called if you create something on the stack, e.g. for: string s; string*s = new string(); bot</description>
   <guid isPermaLink="true">https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15406#p15406</guid>
   <pubDate>Mon, 23 Jun 2008 10:54:11 CDT</pubDate>
   <category>Coding</category>
   <author>nobody@example.com (David Haley)</author>
  </item>
  <item>
   <title>A nice fat stumper for you all</title>
   <link>https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15403#p15403</link>
   <description>[quote=Samson] From &amp;quot;man calloc&amp;quot;: [quote]calloc()  allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the allo-cated memory.  The memory is set to zero.  If nmemb or size is 0, then  calloc()  returns  either  NULL,  or  a unique pointer value that can later be successfully passed to free(). malloc()  allocates  size  bytes and returns a pointer to the allocated memory.  The memory is not cleared.  If size is 0, then malloc() returns either NULL, or </description>
   <guid isPermaLink="true">https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15403#p15403</guid>
   <pubDate>Sun, 22 Jun 2008 14:23:57 CDT</pubDate>
   <category>Coding</category>
   <author>nobody@example.com (Noplex)</author>
  </item>
  <item>
   <title>A nice fat stumper for you all</title>
   <link>https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15402#p15402</link>
   <description>Ooo, double thread necromancy! That&#039;s gotta be worth some extra points or something :P From &amp;quot;man calloc&amp;quot;: [quote]calloc()  allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the allo-cated memory.  The memory is set to zero.  If nmemb or size is 0, then  calloc()  returns  either  NULL,  or  a unique pointer value that can later be successfully passed to free(). malloc()  allocates  size  bytes and returns a pointer to the allocated memory.  The me</description>
   <guid isPermaLink="true">https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15402#p15402</guid>
   <pubDate>Sun, 22 Jun 2008 13:57:34 CDT</pubDate>
   <category>Coding</category>
   <author>nobody@example.com (Samson)</author>
  </item>
  <item>
   <title>A nice fat stumper for you all</title>
   <link>https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15401#p15401</link>
   <description>[quote=DavidHaley]You need to initialize it with &#039;new&#039; if you want the constructor to be called.[/quote] If you need a pointer you need to initialize it with new. The default constructor (if one exists) will be called as long as you don&#039;t allocate a block of memory with malloc. A constructor will also be called, if one exists, if an assignment operation is used and there is no explicit keyword before the constructor.  Examples: [code] class foo { public: foo(void) { std::cout &amp;lt;&amp;lt; &amp;quot;de</description>
   <guid isPermaLink="true">https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=15401#p15401</guid>
   <pubDate>Sun, 22 Jun 2008 12:22:59 CDT</pubDate>
   <category>Coding</category>
   <author>nobody@example.com (Noplex)</author>
  </item>
  <item>
   <title>A nice fat stumper for you all</title>
   <link>https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=13593#p13593</link>
   <description>It&#039;s perfectly fine to have constructors in structs. A class is nothing more than a struct with visibility modifiers. The problem is that if you initialize an object with malloc, the constructor is not called. You need to initialize it with &#039;new&#039; if you want the constructor to be called. (Similarly for destroying it with free vs. delete.)</description>
   <guid isPermaLink="true">https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=13593#p13593</guid>
   <pubDate>Mon, 10 Dec 2007 01:06:04 CST</pubDate>
   <category>Coding</category>
   <author>nobody@example.com (David Haley)</author>
  </item>
  <item>
   <title>A nice fat stumper for you all</title>
   <link>https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=13588#p13588</link>
   <description>Heh. The joy of old posts. At some point I figured out what was wrong with this since the test command loads and outputs what I was expecting it to. It&#039;s too bad the rest of my code is in such disarray at the moment or I might be able to remember why I was doing this to begin with.</description>
   <guid isPermaLink="true">https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=13588#p13588</guid>
   <pubDate>Sat, 8 Dec 2007 22:26:15 CST</pubDate>
   <category>Coding</category>
   <author>nobody@example.com (Samson)</author>
  </item>
  <item>
   <title>A nice fat stumper for you all</title>
   <link>https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=13587#p13587</link>
   <description>[quote=Samson][code] struct weapontable { weapontable(); char *flags;  /* Default flag set */ char *name;   /* Descriptive name */ float weight; /* Base weight */ float cost;   /* Base cost/value */ short type;   /* Weapon type */ short wd;     /* Base damage */ short skill;  /* Skill type */ short damage; /* Damage type */ }; vector&amp;lt;weapontable*&amp;gt; w_table; weapontable::weapontable() { init_memory( &amp;amp;flags, &amp;amp;damage, sizeof( damage ) ); } [/code</description>
   <guid isPermaLink="true">https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=13587#p13587</guid>
   <pubDate>Sat, 8 Dec 2007 18:26:17 CST</pubDate>
   <category>Coding</category>
   <author>nobody@example.com (Quixadhal)</author>
  </item>
  <item>
   <title>A nice fat stumper for you all</title>
   <link>https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=4103#p4103</link>
   <description>Don&#039;t know why I didn&#039;t try this before, but I threw the code up on Cygwin and had at it. Since it uses older gcc 3.4.4, I figured it might ferret out a potential compiler problem. Well, that&#039;s exactly what this turned out to be. Without altering a single line of code, Cygwin compiled it and ran it without crashing. Which is why I was stumped. Perfectly valid code crashing out for no explainable reason. I&#039;d file a bug against the compiler for this, but I wouldn&#039;t know where to begin. Isolatin</description>
   <guid isPermaLink="true">https://smaugmuds.afkmods.com/topic/a-nice-fat-stumper-for-you-all-1121/&amp;p=4103#p4103</guid>
   <pubDate>Mon, 20 Mar 2006 08:48:31 CST</pubDate>
   <category>Coding</category>
   <author>nobody@example.com (Samson)</author>
  </item>
 </channel>
</rss>
