<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>doline error help plz</title>
		<link>http://www.allegro.cc/forums/view/591051</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 19 Apr 2007 05:08:42 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>



class NPC<br />{<br />     int targetx,targety,x,y;<br />     <br />     void movenpc()//doline is in this function<br />     void drawb()//the function that is used by doline<br />     <br />     void npcset()<br />};<br />     </p><p>I keep getting an error that says:</p><p>ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function.  Say `&amp;NPC::drawb&#39; </p><p>the error leads to a line with this code:<br />do_line(all,x,y,targetx,targety,0,&amp;drawb);</p><p>can somone plz help
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (meinaW)</author>
		<pubDate>Tue, 17 Apr 2007 16:32:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://www.google.com/search?q=c%2B%2B+member+function+callback&amp;btnI=whee">http://www.google.com/search?q=c%2B%2B+member+function+callback&amp;btnI=whee</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Inphernic)</author>
		<pubDate>Tue, 17 Apr 2007 16:35:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">class</span> NPC</td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td><span class="k1">int</span> m_nTargetX,m_nTargetY,m_nX,m_nY<span class="k2">;</span></td></tr><tr><td class="number">4</td><td>&#160;</td></tr><tr><td class="number">5</td><td><span class="c">//doline is in this function</span></td></tr><tr><td class="number">6</td><td><span class="k1">void</span> moveNPC<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">7</td><td>&#160;</td></tr><tr><td class="number">8</td><td><span class="c">//the function that is used by doline</span></td></tr><tr><td class="number">9</td><td><span class="k1">void</span> draw<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>&#160;</td></tr><tr><td class="number">11</td><td><span class="k1">void</span> setNPC<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td><span class="k2">}</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>&#160;</td></tr><tr><td class="number">14</td><td>&#160;</td></tr><tr><td class="number">15</td><td><span class="k1">void</span> NPC::moveNPC<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">16</td><td><span class="k2">{</span></td></tr><tr><td class="number">17</td><td>    <a href="http://www.allegro.cc/manual/do_line" target="_blank"><span class="a">do_line</span></a><span class="k2">(</span>pBitmap, nX, nY, nX2, nY2, nD, draw<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">18</td><td>&#160;</td></tr><tr><td class="number">19</td><td><span class="k2">}</span></td></tr><tr><td class="number">20</td><td>&#160;</td></tr><tr><td class="number">21</td><td>&#160;</td></tr><tr><td class="number">22</td><td><span class="k1">void</span> NPC::draw<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>a_pBitmap, <span class="k1">int</span> a_nX, <span class="k1">int</span> a_nY, <span class="k1">int</span> a_nD<span class="k2">)</span></td></tr><tr><td class="number">23</td><td><span class="k2">{</span></td></tr><tr><td class="number">24</td><td>&#160;</td></tr><tr><td class="number">25</td><td><span class="k2">}</span></td></tr><tr><td class="number">26</td><td>&#160;</td></tr><tr><td class="number">27</td><td><span class="k1">void</span> NPC::setNPC<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">28</td><td><span class="k2">{</span></td></tr><tr><td class="number">29</td><td>&#160;</td></tr><tr><td class="number">30</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

Try this coding style <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ariesnl)</author>
		<pubDate>Tue, 17 Apr 2007 18:57:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Try this coding style <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div></div><p>Because coding style affects the ability to pass member functions through C function pointers <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /></p><p>Inphernic has it, of course. Also check out <a href="http://www.allegro.cc/forums/search/f5565b46ba22f2e409eaaaa9ad5ae503">this link</a>, which is just results on this forum (people using timers have this problem a lot).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Tue, 17 Apr 2007 20:39:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>thanks all<br />i got it working now all i did was change:</p><p>void bdraw();         <br />to       <br />void static bdraw();</p><p>do_line(all,x,y,targetx,targety,0,&amp;drawb);<br />to<br />do_line(all,x,y,targetx,targety,0,*drawb);</p><p>seems to work pretty well</p><p>[EDIT]<br />never mind now it gives me this error:</p><p>invalid use of member `NPC::laserx&#39; in static member function </p><p>why do c++ callbacks have to be so hard:(</p><p>[EDIT]<br />I give up ,I&#39;m just going to use a diffrent line algorithm
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (meinaW)</author>
		<pubDate>Wed, 18 Apr 2007 04:01:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You used a non-static field in a static function.</p><p>Static functions belong to the classes themselves, not the objects, and do not know about specific objects.</p><p>Try passing a pointer to the object as the <tt>int d</tt> parameter of <tt>do_line()</tt>.</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">static</span> <span class="k1">void</span> NPC::bdraw<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>_bitmap, <span class="k1">int</span> _x, <span class="k1">int</span> _y, <span class="k1">int</span> _d<span class="k2">)</span>
<span class="k2">{</span>
    CObject<span class="k3">*</span> obj <span class="k3">=</span> <span class="k2">(</span>CObject<span class="k3">*</span><span class="k2">)</span>_d<span class="k2">;</span> <span class="c">//the object pointer we snuck in</span>
    <span class="c">//do other stuff</span>
<span class="k2">}</span>

<span class="k1">void</span> NPC::movenpc<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
    <a href="http://www.allegro.cc/manual/do_line" target="_blank"><span class="a">do_line</span></a><span class="k2">(</span>buffer, x, y, targetx, targety, <span class="k2">(</span><span class="k1">int</span><span class="k2">)</span><span class="k1">this</span>, bdraw<span class="k2">)</span><span class="k2">;</span>
    <span class="c">//do other stuff</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Wed, 18 Apr 2007 08:35:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks everyone for help i used BresenhamLine algorithm instead of do_line and everything works now with no errors
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (meinaW)</author>
		<pubDate>Wed, 18 Apr 2007 09:38:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Because coding style affects the ability to pass member functions through C function pointers
</p></div></div><p>

No it affects the ability to read the code <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>besides I gave an answer aswell if you lookend at my code
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ariesnl)</author>
		<pubDate>Wed, 18 Apr 2007 12:02:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you&#39;re referring to the lack of an ampersand on the reference to draw, it&#39;s invalid, and it doesn&#39;t fix the error.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Wed, 18 Apr 2007 19:23:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Try passing a pointer to the object as the int d parameter of do_line().
</p></div></div><p>
Ah!  ew!  My eyes!
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="c">// In a .cpp file</span></td></tr><tr><td class="number">2</td><td><span class="p">#include &lt;vector&gt;</span></td></tr><tr><td class="number">3</td><td>&#160;</td></tr><tr><td class="number">4</td><td><span class="k1">static</span> std::vector<span class="k3">&lt;</span>CObject<span class="k3">*</span><span class="k3">&gt;</span> bdraw_refs<span class="k2">;</span></td></tr><tr><td class="number">5</td><td>&#160;</td></tr><tr><td class="number">6</td><td><span class="k1">static</span> <span class="k1">void</span> NPC::bdraw<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>_bitmap, <span class="k1">int</span> _x, <span class="k1">int</span> _y, <span class="k1">int</span> _d<span class="k2">)</span></td></tr><tr><td class="number">7</td><td><span class="k2">{</span></td></tr><tr><td class="number">8</td><td>    CObject<span class="k3">*</span> obj <span class="k3">=</span> <span class="k2">(</span>CObject<span class="k3">*</span><span class="k2">)</span>bdraw_refs<span class="k2">[</span>_d<span class="k2">]</span><span class="k2">;</span> <span class="c">//the object pointer we snuck in</span></td></tr><tr><td class="number">9</td><td>    <span class="c">//do other stuff</span></td></tr><tr><td class="number">10</td><td><span class="k2">}</span></td></tr><tr><td class="number">11</td><td>&#160;</td></tr><tr><td class="number">12</td><td><span class="k1">void</span> NPC::movenpc<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">13</td><td><span class="k2">{</span></td></tr><tr><td class="number">14</td><td>    bdraw_refs.push_back<span class="k2">(</span><span class="k1">this</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>    <a href="http://www.allegro.cc/manual/do_line" target="_blank"><span class="a">do_line</span></a><span class="k2">(</span>buffer, x, y, targetx, targety, <span class="k2">(</span><span class="k1">int</span><span class="k2">)</span>bdraw_refs.size<span class="k2">(</span><span class="k2">)</span> <span class="k3">-</span> <span class="n">1</span>, bdraw<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">16</td><td>    <span class="c">//do other stuff</span></td></tr><tr><td class="number">17</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

I&#39;m not even going to comment on the name &#39;CObject&#39; or the underscores perpended to those parameters...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Thu, 19 Apr 2007 00:36:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I&#39;m not even going to comment on the name &#39;CObject&#39; or the underscores perpended to those parameters...
</p></div></div><p>

Microsoft strikes again! I&#39;m always reminded of this quote:</p><div class="quote_container"><div class="title">The Linux kernel coding style guide said:</div><div class="quote"><p>

Encoding the type of a function into the name (so-called Hungarian notation) is brain damaged - the compiler knows the types anyway and can check those, and it only confuses the programmer. No wonder Microsoft makes buggy programs.
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Rampage)</author>
		<pubDate>Thu, 19 Apr 2007 02:17:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This is an argument I have with students I tutor all the time, it made sense to use it back when compilers didn&#39;t do much in the way of checking data-types, now its at the opposite end of the scale (with c++ anyway) wanting you to cast everything.</p><p>I can&#39;t really complain though I use all upper case for my class/struct names <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><div class="source-code snippet"><div class="inner"><pre><span class="k1">class</span> BULLET <span class="k2">:</span> <span class="k1">public</span> OBJECT
<span class="k2">{</span>
...
<span class="k2">}</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Timorg)</author>
		<pubDate>Thu, 19 Apr 2007 04:35:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I&#39;m not even going to comment on the name &#39;CObject&#39; or the underscores perpended to those parameters...
</p></div></div><p>

Hahaha, I change styles at will. Recently I&#39;ve been reading Game Coding Complete and ZoidCom&#39;s manual. The former uses C before all classes that aren&#39;t interfaces (those get an I, singletons get no prefix) and the latter uses _ for parameters.</p><p>I don&#39;t see what&#39;s wrong with either of those, though. I always found it pretty nifty to be able to distinguish parameters from locals, so I try to use that style when I think of it, but maybe that&#39;s just me. And what&#39;s wrong with CObject? If it&#39;s just Object, how do you know it&#39;s not an interface? Also makes code completion a bit better, in case you want to use an interface but don&#39;t recall the specific name you can narrow it down in an instant.</p><p>***</p><p>Oh, I thought you just re-posted my code, which I thought was quite strange. But I see you added some lines. ...I don&#39;t really understand why you would do it that way, did I miss something?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Thu, 19 Apr 2007 04:35:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Part of the reason I dislike Java so much is the idea that all class&#39; should for some reason inherit from some Object class.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Oh, I thought you just re-posted my code, which I thought was quite strange. But I see you added some lines. ...I don&#39;t really understand why you would do it that way, did I miss something?
</p></div></div><p>
You&#39;re assuming the size of a pointer == the size of an int.  Which is an invalid and dangerous assumption.</p><p>As a random side note, Allegro&#39;s internals also make this assumption.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Thu, 19 Apr 2007 04:36:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Part of the reason I dislike Java so much is the idea that all class&#39; should for some reason inherit from some Object class.
</p></div></div><p>

Who brought up Java? I use &quot;object&quot; as a generic term for a class. What would you have me use instead, so I don&#39;t offend you in the future? <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
You&#39;re assuming the size of a pointer == the size of an int. Which is an invalid and dangerous assumption.
</p></div></div><p>

Oh, understood. Then why would you need a vector to store them in? Why not just have a single static <tt>CObject*</tt>?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Thu, 19 Apr 2007 04:38:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Oh, understood. Then why would you need a vector to store them in? Why not just have a single static CObject*?
</p></div></div><p>
General inter-ability.  Maybe one day (aka this happens a lot) you&#39;ll want to use the callback for uses whose state last longer then the function call.  It also is a good step towards thread safety (for some operations, even though in this one you could just mutex the do_line call).</p><p>Really its just good callback habit (when you can&#39;t pass an actual pointer*).<br /><sub>


* edited in afterwards
</sub>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Thu, 19 Apr 2007 04:44:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My OBJECT isn&#39;t just deriving for the sake of deriving (aka java)</p><p>Its a world object</p><p>class OBJECT<br />{<br />	public:<br />		OBJECT();<br />		virtual ~OBJECT()<br />		virtual void logic() = 0;<br />		virtual void render(BITMAP *buffer) = 0;<br />		virtual void kill() = 0;<br />		POINT location;<br />		bool dead;<br />		int mode;<br />		int colour;<br />};</p><p><img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Timorg)</author>
		<pubDate>Thu, 19 Apr 2007 04:48:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>However, this whole thread brings up a good point, and maybe we should add a do_line_ex that accepts a void* d instead of an int d...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Thu, 19 Apr 2007 04:50:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
However, this whole thread brings up a good point, and maybe we should add a do_line_ex that accepts a void* d instead of an int d...
</p></div></div><p>

Yeah, I just looked up <tt>install_param_int_ex</tt> and thought the same thing... How come that one is <tt>void*</tt> and this is <tt>int</tt>?</p><p>Edit: I still wanna know about those coding practices, though. Is there a reason why they&#39;re bad?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Thu, 19 Apr 2007 04:53:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This is an int because you can pass putpixel to it:<br /><span class="source-code"><a href="http://www.allegro.cc/manual/do_line" target="_blank"><span class="a">do_line</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, <span class="n">0</span>, <span class="n">0</span>, <a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a> <span class="k3">-</span> <span class="n">1</span>, <a href="http://www.allegro.cc/manual/SCREEN_H" target="_blank"><span class="a">SCREEN_H</span></a> <span class="k3">-</span> <span class="n">1</span>, <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">255</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span>, <a href="http://www.allegro.cc/manual/putpixel" target="_blank"><span class="a">putpixel</span></a><span class="k2">)</span><span class="k2">;</span></span></p><p>Or you can write a special putpixel that does something slightly different, but shares the same prototype. Enter object oriented programming and just screw everything up <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Thu, 19 Apr 2007 04:58:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Enter object oriented programming and just screw everything up <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div></div><p>

Yes...</p><p>Edit: Also, since we have <tt>do_line()</tt>, shouldn&#39;t we also have <tt>dont_do_line()</tt>?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Thu, 19 Apr 2007 05:08:42 +0000</pubDate>
	</item>
</rss>
