<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Class Vectors</title>
		<link>http://www.allegro.cc/forums/view/586024</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 21 Jun 2006 21:23:49 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OK, I am using a vector to store information about my characters and currently, for me, it is not possible to access the vector from another source file. How would I go about that? I&#39;ve tried extern vector in the header, but it wouldn&#39;t compile.</p><p>Secondly, I can&#39;t access the Class outside the source file. This is the code so far:</p><p>main.cpp:
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">//Some variables</span>
player <span class="k3">*</span>local_player<span class="k2">;</span>  <span class="c">//Compiles fine</span>
<span class="c">//More variables</span>
</pre></div></div><p>

main.h:
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">//Some variables</span>
<span class="k1">extern</span> player <span class="k3">*</span>local_player<span class="k2">;</span>  <span class="c">//main.h:44: error: expected initializer before '*' token</span>
<span class="c">//More variables</span>
</pre></div></div><p>

If I don&#39;t have the declaration in the header:<br />game.cpp:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> init_game<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span> <span class="k2">{</span>
  <span class="c">//some stuff</span>
  local_player <span class="k3">=</span> <span class="k1">new</span> player<span class="k2">(</span><span class="n">1000</span> <span class="c">/*player x*/</span>, <span class="n">1000</span> <span class="c">/*player x*/</span>, <span class="n">1</span> <span class="c">/*player d*/</span>, name, img_ship<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>     <span class="c">//game.cpp:11: error: 'local_player' was not declared in this scope</span>
  players.push_back<span class="k2">(</span>local_player<span class="k2">)</span><span class="k2">;</span>     <span class="c">//game.cpp:12: error: 'players' was not declared in this scope</span>
  <span class="c">//some more stuff</span>
</pre></div></div><p>

Also note, the thing about &#39;players&#39; not being declared. That&#39;s because I can&#39;t extern the vector.</p><p>EDIT:<br />If you need more info, ask and I can post it.</p><p>EDIT2:<br />Whilst I&#39;m here, is it possible to change the colours on the file select dialog?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Stanley)</author>
		<pubDate>Wed, 21 Jun 2006 21:06:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You need to include the header file with the player class in it in main.h.</p><p><span class="source-code"><a href="http://www.allegro.cc/manual/gui_fg_color" target="_blank"><span class="a">gui_fg_color</span></a>, <a href="http://www.allegro.cc/manual/gui_bg_color" target="_blank"><span class="a">gui_bg_color</span></a></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Wed, 21 Jun 2006 21:10:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, I have, I thought that went without saying...</p><p>Thanks for the gui stuff though
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Stanley)</author>
		<pubDate>Wed, 21 Jun 2006 21:16:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Have you tried to put std::vector instead of plain vector in header?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Wed, 21 Jun 2006 21:18:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I know it&#39;s bad practice, but I&#39;m &#39;using namespace std&#39;, so I don&#39;t think I need to. I&#39;ll go try
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Stanley)</author>
		<pubDate>Wed, 21 Jun 2006 21:20:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
<tt>main.h:44: error: expected initializer before &#39;*&#39; token</tt>
</p></div></div><p>This means that the type &#39;player&#39; is not defined. Either you have other compile errors you need to work out first (see Hoho&#39;s post), or you haven&#39;t declared the class at all (i.e. not included the header).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Wed, 21 Jun 2006 21:21:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Alright, it&#39;ll probably be in the other errors then, but I think they&#39;re caused by it... Anyway, I got to have tea now, be back later.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Stanley)</author>
		<pubDate>Wed, 21 Jun 2006 21:23:49 +0000</pubDate>
	</item>
</rss>
