<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DaniWeb IT Discussion Community - C++</title>
		<link>http://www.daniweb.com/forums/</link>
		<description><![CDATA[Our C++ forum is the place for Q&A-style discussions related to this popular language.  Note we have a separate C forum for non-OOP straight C. Please direct C++ questions directly related to game development to our Game Development forum.]]></description>
		<language>en-US</language>
		<lastBuildDate>Sat, 28 Nov 2009 15:07:17 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.daniweb.com/alphaimages/misc/rss.jpg</url>
			<title>DaniWeb IT Discussion Community - C++</title>
			<link>http://www.daniweb.com/forums/</link>
		</image>
		<item>
			<title>How to read lines in C++ from file.</title>
			<link>http://www.daniweb.com/forums/thread242023.html</link>
			<pubDate>Sat, 28 Nov 2009 14:26:21 GMT</pubDate>
			<description><![CDATA[Example of what im trying to do: 
 
_Definition: test.txt_ 
 
Apples //line1 
Coke //line2 
Money/line3 
 
C++ code: 
#include <fstream>]]></description>
			<content:encoded><![CDATA[<div>Example of what im trying to do:<br />
<br />
<span style="text-decoration:underline">Definition: test.txt</span><br />
<br />
Apples //line1<br />
Coke //line2<br />
Money/line3<br />
<br />
C++ code:<br />
#include &lt;fstream&gt;<br />
using namespace std;<br />
fstream teststream;<br />
teststream.open(&quot;test.txt&quot;);<br />
string line1;<br />
string line2;<br />
string line3;<br />
<br />
//I want it so line1 = apples<br />
//I wan tit so line2 = coke<br />
//I want it so line3 = money<br />
<br />
I'm not sure how to do this, so any help would be very appreciated :).</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Kennych</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread242023.html</guid>
		</item>
		<item>
			<title>Very, very new self-teacher asking for help</title>
			<link>http://www.daniweb.com/forums/thread242021.html</link>
			<pubDate>Sat, 28 Nov 2009 14:12:59 GMT</pubDate>
			<description><![CDATA[First off, I'm a complete and absolute programming newbie and a bit of an old fart to boot, so I'd appreciate a gentle-but-firm correction if I'm pushing the wrong buttons here.   
 
I'm slowly working through a used copy of Prata's C++ 5th edition, but something's not working in my version of one...]]></description>
			<content:encoded><![CDATA[<div>First off, I'm a complete and absolute programming newbie and a bit of an old fart to boot, so I'd appreciate a gentle-but-firm correction if I'm pushing the wrong buttons here.  <br />
<br />
I'm slowly working through a used copy of Prata's C++ 5th edition, but something's not working in my version of one of the early chapter challenges.  Maybe I've just been staring at it too long (I've rewritten this snippet from scratch twice), but I can't figure what's going wrong, and I'm spooked to try to pare this down for a forum post, so here goes.<br />
<br />
 <pre style="margin:20px; line-height:13px">// mpg.cpp -- A converter to change European fuel efficiency<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numbers over to American standards.<br />
<br />
#include &lt;iostream&gt;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; using namespace std;<br />
&nbsp; &nbsp; const float KM_MI = 1.609; // km per mile<br />
&nbsp; &nbsp; const float L_G = 0.2642;&nbsp; // liters per gallon<br />
&nbsp; &nbsp; float mi, gal, mpg;&nbsp; &nbsp; &nbsp; &nbsp; // American<br />
&nbsp; &nbsp; float l, km, l_km;&nbsp; &nbsp; &nbsp; &nbsp;  // continental<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;The km driven? &quot;;<br />
&nbsp; &nbsp; cin &gt;&gt; km;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;...and the liters used? &quot;;<br />
&nbsp; &nbsp; cin &gt;&gt; l;<br />
&nbsp; &nbsp; l_km = l / (km / 100);<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;That's &quot; &lt;&lt; l_km &lt;&lt; &quot; liters per 100 km.&nbsp; \n&quot;;<br />
&nbsp; &nbsp; mi = KM_MI * km;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; gal = L_G * l;<br />
&nbsp; &nbsp; mpg = mi / gal;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // ???<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Or, &quot; &lt;&lt; mi &lt;&lt; &quot; miles using &quot;;<br />
&nbsp; &nbsp; cout &lt;&lt; gal &lt;&lt; &quot; gallons of fuel.&nbsp; \nThat's a total of &quot;;<br />
&nbsp; &nbsp; cout &lt;&lt; mpg &lt;&lt; &quot; miles per gallon.&quot;;<br />
&nbsp; &nbsp; return 0;<br />
}</pre>This returns...<br />
 <pre style="margin:20px; line-height:13px">The km driven? 100<br />
...and the liters used? 12.4<br />
That's 12.4 liters per 100 km.<br />
Or, 160.9 miles using 3.27608 gallons of fuel.<br />
That's a total of 49.1136 miles per gallon.</pre><br />
According to the book and a (supposedly functional) online calculator, 12.4 l/100km should return ~19 MPG.  I must be fumbling my math somehow, but I can't get my head around it, since my miles and gallons seem to be converting properly, and the MPG equation is simply mi / gal, right?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>grib</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread242021.html</guid>
		</item>
		<item>
			<title>Deleting elements from array</title>
			<link>http://www.daniweb.com/forums/thread242018.html</link>
			<pubDate>Sat, 28 Nov 2009 13:56:22 GMT</pubDate>
			<description><![CDATA[Hi, I need to make a program, which I think should be simple if you know what you are doing. 
 
You have an array of integers A(m, n) and B(m). Delete an element from A array, which index is in the B(m) array. Print original and modified arrays. 
 
I don't really know how should I do it. I have...]]></description>
			<content:encoded><![CDATA[<div>Hi, I need to make a program, which I think should be simple if you know what you are doing.<br />
<br />
You have an array of integers A(m, n) and B(m). Delete an element from A array, which index is in the B(m) array. Print original and modified arrays.<br />
<br />
I don't really know how should I do it. I have made two files for the input (for A and B) and made the program to compile and present the result in the output file. Now, the only thing left is this function. Any help would be appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Snippset</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread242018.html</guid>
		</item>
		<item>
			<title>String is not included problem</title>
			<link>http://www.daniweb.com/forums/thread242010.html</link>
			<pubDate>Sat, 28 Nov 2009 12:34:17 GMT</pubDate>
			<description><![CDATA[So  here is the problem. This won't compile. It always gives an error like : 
d.cpp:24: error: ‘string’ was not declared in this scope 
d.cpp:24: error: expected ‘,’ or ‘;’ before ‘{’ token 
Compilatie failed. 
 
#include <iostream> 
#include <string> 
#include <stdlib.h> 
#include <time.h> 
int...]]></description>
			<content:encoded><![CDATA[<div>So  here is the problem. This won't compile. It always gives an error like :<br />
d.cpp:24: error: ‘string’ was not declared in this scope<br />
d.cpp:24: error: expected ‘,’ or ‘;’ before ‘{’ token<br />
Compilatie failed.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;time.h&gt;<br />
int d(int amount, int dots){ // d(X,Y) notation.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* initialize random seed: */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; srand (time(NULL));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int sum = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int temp = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt;amount ; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = rand() % dots + 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum = sum + temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return sum;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />
int d(int dots){ <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int temp = d(1, dots);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
int extract_d(string s){<br />
&nbsp; &nbsp; &nbsp; &nbsp; int stringsize = s.size();<br />
&nbsp; &nbsp; &nbsp; &nbsp; int eindwaarden&#91;3&#93; = {0,0,0};<br />
&nbsp; &nbsp; &nbsp; &nbsp; int waarde = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int eerstekeer = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int count = 0; count &lt; stringsize; count++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(s&#91;count&#93; == 100 || s&#91;count&#93; == 43){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; waarde++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(eerstekeer == 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eindwaarden&#91;waarde&#93; = s&#91;count&#93; - '0';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eerstekeer++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eindwaarden&#91;waarde&#93; *= 10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eindwaarden&#91;waarde&#93; += s&#91;count&#93; - '0';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return (d(eindwaarden&#91;0&#93;,eindwaarden&#91;1&#93;)) +&nbsp; &nbsp; &nbsp; &nbsp; eindwaarden&#91;2&#93;;<br />
}</pre><br />
And i don't really see the problem, i included string right?<br />
Please help....</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kevinn</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread242010.html</guid>
		</item>
		<item>
			<title>Traveling Salesman Problem</title>
			<link>http://www.daniweb.com/forums/thread242008.html</link>
			<pubDate>Sat, 28 Nov 2009 12:21:04 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I'm supposed to write a code of my TSP assignment using brute force algorithm. Although there are still some darkness about how to do it. I know what is TSP but I don't know how to start it. 
 
Let's say that we have 4 cities(A, B, C, D). Using brute force am I supposed to do ABCDA, ACDBA,...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I'm supposed to write a code of my TSP assignment using brute force algorithm. Although there are still some darkness about how to do it. I know what is TSP but I don't know how to start it.<br />
<br />
Let's say that we have 4 cities(A, B, C, D). Using brute force am I supposed to do ABCDA, ACDBA, ADCBA and ... then save all the total cost for each and decide based on those???<br />
<br />
BTW, I'm supposed to read the data from a file that gives the cities coordination.<br />
<br />
Please let me know if some more information is needed.<br />
<br />
Thanks a lot.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>group256</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread242008.html</guid>
		</item>
		<item>
			<title>Odd problem with my code output...</title>
			<link>http://www.daniweb.com/forums/thread242000.html</link>
			<pubDate>Sat, 28 Nov 2009 11:38:16 GMT</pubDate>
			<description><![CDATA[Hello everyone,  
 
First, please excuse the sloppy-ish coding.  I'm working on my ability to shorten my code as we speak.  However, being new to this, the hardest way seems to be what I always end up doing.  
 
That said - on to my problem.   
 
I wrote this code for a programming class of mine. ...]]></description>
			<content:encoded><![CDATA[<div>Hello everyone, <br />
<br />
First, please excuse the sloppy-ish coding.  I'm working on my ability to shorten my code as we speak.  However, being new to this, the hardest way seems to be what I always end up doing. <br />
<br />
That said - on to my problem.  <br />
<br />
I wrote this code for a programming class of mine.  While the code does execute properly (from what I can tell, with limited testing), I receive a weird error on the output.  <br />
<br />
No matter how I try executing the checks, the first error found on the row will output after both the columns and the 3x3 grid.  All subsequent errors will output in the correct spot however.  <br />
<br />
The output should look like:<br />
<br />
row error<br />
row error<br />
column error<br />
column error<br />
3x3 grid error<br />
3x3 grid error<br />
<br />
However, it appears as:<br />
<br />
row error<br />
column error<br />
column error<br />
3x3 grid error<br />
3x3 grid error<br />
row error<br />
<br />
The purpose of this code is to verify a sudoku solution.  Any errors will be reported with their block, line, and column (the first instance of the number will not be reported, only the extras that follow).  There is a lot of output right now which is for debugging purposes.<br />
<br />
In the code below, I have included a sudoku puzzle with 2 errors.  Row 1, Column 1 should be a 7, not a 5, and Row 2, Column 1 should be a 4, not a 5.<br />
<br />
The code is ready to be run/complied, so there should be no modifications necessary in order to reproduce the error I keep seeing.  <br />
<br />
Any help on this would be greatly appreciated!<br />
<br />
Thanks in advance.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
<br />
using namespace std;<br />
<br />
const int grid = 9;<br />
const int block = 3;<br />
<br />
void fRef();<br />
void chkMat();<br />
void chkRow(int x);<br />
void chkCol(int x);<br />
void chkBlk(int x);<br />
void chkMsng(int x, int y, int z);<br />
void fixRef();<br />
void error(const int x, const int y, const int r);<br />
void printGrid(const int x[][grid]);<br />
<br />
int refMat[grid][grid] = {0};<br />
int matrix[grid][grid] = {5,9,2,6,8,4,5,1,3,5,5,1,9,7,3,8,2,6,6,8,3,5,2,1,7,4,9,5,2,9,7,4,8,3,6,1,1,6,7,2,3,9,4,8,5,8,3,4,1,5,6,2,9,7,3,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4,6,8,9,7,1,5,2,9,7,5,4,1,2,6,3,8,2,1,8,3,6,5,9,7,4};<br />
<br />
int main()<br />
{<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; fRef();<br />
&nbsp; &nbsp; &nbsp; &nbsp; chkMat();<br />
&nbsp; &nbsp; &nbsp; &nbsp; printGrid(matrix);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;); return 0;<br />
}<br />
void fRef()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; grid; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; refMat[i][0] = i+1;<br />
}<br />
void chkMat()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; grid; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chkRow(i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chkCol(i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chkBlk(i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
void chkRow(int x)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int tmp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; grid; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmp=matrix[x-1][i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; refMat[tmp-1][1]++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (refMat[tmp-1][1] &gt; 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error(i,(x-1),tmp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j &lt; grid; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (refMat[j][1] == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chkMsng(j+1, x, 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fixRef();<br />
}<br />
void chkCol(int x)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int tmp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; grid; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmp=matrix[i][x-1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; refMat[tmp-1][1]++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (refMat[tmp-1][1] &gt; 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error((x-1),i,tmp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j &lt; grid; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (refMat[j][1] == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chkMsng(j+1, x,&nbsp; 2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fixRef();<br />
}<br />
void chkBlk(int x)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int mOf, nOf;<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(x)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; case 1: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mOf = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nOf = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mOf = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nOf = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mOf = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nOf = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 4: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mOf = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nOf = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 5:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mOf = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nOf = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 6:&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mOf = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nOf = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 7: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mOf = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nOf = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 8:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mOf = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nOf = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 9:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mOf = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nOf = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int blk[block][block] = {0};<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int m = 0; m &lt; block; m++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int n = 0; n &lt; block; n++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blk[m][n] = matrix[m+mOf][n+nOf];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int tmp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; block; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j &lt; block; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmp=blk[i][j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; refMat[tmp-1][1]++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (refMat[tmp-1][1] &gt; 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error((i+mOf),(j+nOf),tmp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j &lt; grid; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (refMat[j][1] == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chkMsng(j+1, x, 3);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fixRef();<br />
}<br />
void chkMsng(int x, int y, int z)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (z == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Row &quot;&lt;&lt;y&lt;&lt;&quot; is missing a &quot;&lt;&lt;x&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (z == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Column &quot;&lt;&lt;y&lt;&lt;&quot; is missing a &quot;&lt;&lt;x&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (z == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;3x3 grid number &quot;&lt;&lt;y&lt;&lt;&quot; is missing a &quot;&lt;&lt;x&lt;&lt;endl;<br />
}<br />
void fixRef()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; grid; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; refMat[i][1] = 0;<br />
}<br />
void error(const int x, const int y, const int r)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int blk;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((y == 0 || y == 1 || y == 2 ) &amp;&amp; ( x == 0 || x == 1 || x == 2))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blk = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if ((y == 0 || y == 1 || y == 2 ) &amp;&amp; ( x == 3 || x == 4 || x == 5))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blk = 2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if ((y == 0 || y == 1 || y == 2 ) &amp;&amp; ( x == 6 || x == 7 || x == 8))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blk = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if ((y == 3 || y == 4 || y == 5 ) &amp;&amp; ( x == 0 || x == 1 || x == 2))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blk = 4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if ((y == 3 || y == 4 || y == 5 ) &amp;&amp; ( x == 3 || x == 4 || x == 5))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blk = 5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if ((y == 3 || y == 4 || y == 5 ) &amp;&amp; ( x == 6 || x == 7 || x == 8))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blk = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if ((y == 6 || y == 7 || y == 8 ) &amp;&amp; ( x == 0 || x == 1 || x == 2))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blk = 7;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if ((y == 6 || y == 7 || y == 8 ) &amp;&amp; ( x == 3 || x == 4 || x == 5))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blk = 8;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if ((y == 6 || y == 7 || y == 8 ) &amp;&amp; ( x == 6 || x == 7 || x == 8))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blk = 9;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Multiple instances of &quot;&lt;&lt;r&lt;&lt;&quot; found in block &quot;&lt;&lt;blk&lt;&lt;&quot;. Overall grid location (&quot;&lt;&lt;x+1&lt;&lt;&quot;, &quot;&lt;&lt;y+1&lt;&lt;&quot;)&quot;&lt;&lt;endl;<br />
}<br />
void printGrid(const int x[][grid])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int iOf = 0, jOf = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int nI = 0, nJ = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int m = 0; m &lt; 3; m++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int n = 0; n &lt; grid; n++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch(n)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 0: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jOf = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jOf = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jOf = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 3: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jOf = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 4:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jOf = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 5:&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jOf = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 6: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jOf = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 7:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jOf = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 8:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jOf = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j &lt; 3; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nJ = (j + jOf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;setw(2)&lt;&lt;x[i][nJ]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Thraxus</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread242000.html</guid>
		</item>
		<item>
			<title>How to add GUI to  a console based application using a precompiled library</title>
			<link>http://www.daniweb.com/forums/thread241992.html</link>
			<pubDate>Sat, 28 Nov 2009 10:27:07 GMT</pubDate>
			<description>hey everyone, 
 
I am working on a project where I have a C++ library (a precompiled library ) that would be used in my application. My application is a Windows based console application.I am working on VisualStudio 6.0. 
I would like to add GUI to this application of mine. 
 
Could you please...</description>
			<content:encoded><![CDATA[<div>hey everyone,<br />
<br />
I am working on a project where I have a C++ library (a precompiled library ) that would be used in my application. My application is a Windows based console application.I am working on VisualStudio 6.0.<br />
I would like to add GUI to this application of mine.<br />
<br />
Could you please suggest a way ?<br />
<br />
I tried the option of &quot;Simple MFC application&quot; appearing after choosing a windows based console application but that shows the following error<br />
<br />
<br />
&quot;fatal error C1010 - unexpected end of file while looking for precompiled header directive&quot;<br />
<br />
I tried fixing it by adding <br />
<br />
#include &quot;stdafx&quot; in all files of my source code,but it dint work.<br />
<br />
Thanks <br />
bk</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bkpally263</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241992.html</guid>
		</item>
		<item>
			<title>Help in Porting Video Server from Linux to Windows</title>
			<link>http://www.daniweb.com/forums/thread241990.html</link>
			<pubDate>Sat, 28 Nov 2009 10:17:03 GMT</pubDate>
			<description>Hello friends , I am doing a project about *Video Streaming in J2ME* . For that project i want to setup a *Video Streaming Serve*r in my system (Windows XP). I got the Source code of a Video Server written in C++ form  *sourceforge.net* . But the documentation explaining that server is for Linux ....</description>
			<content:encoded><![CDATA[<div>Hello friends , I am doing a project about <span style="font-weight:bold">Video Streaming in J2ME</span> . For that project i want to setup a <span style="font-weight:bold">Video Streaming Serve</span>r in my system (Windows XP). I got the Source code of a Video Server written in C++ form  <span style="font-weight:bold">sourceforge.net</span> . But the documentation explaining that server is for Linux . So i decided to port that into Windows . I am stuck with Which compiler have to use the <span style="font-weight:bold">Turbo C++ Dos version</span> or <span style="font-weight:bold">Visual C++2005 </span> . At last i tried with Visual Studio and its showing lot of errors , any one please help me . What i have to do .... please .... <br />
<br />
i am attaching the complete project ........... plz help me</div>  <br /> <div style="padding:5px">     <fieldset class="fieldset"> <legend>Attached Files</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/zip.gif" alt="File Type: zip" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12754&amp;d=1259403332">server.zip</a> (44.9 KB)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>vijaysoft1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241990.html</guid>
		</item>
		<item>
			<title>Hashing Problem</title>
			<link>http://www.daniweb.com/forums/thread241984.html</link>
			<pubDate>Sat, 28 Nov 2009 09:38:20 GMT</pubDate>
			<description><![CDATA[I'm trying to make this simple dictionary using hash table and struct. basically i restore the information in the struct and put the struct into an array of pointer. but my program seems buggy. this program is not  complete yet, so there are still some function missing. but with the current...]]></description>
			<content:encoded><![CDATA[<div>I'm trying to make this simple dictionary using hash table and struct. basically i restore the information in the struct and put the struct into an array of pointer. but my program seems buggy. this program is not  complete yet, so there are still some function missing. but with the current function that are available, my program keeps crashing after the 2 string input. can somebody point out my mistake please ? Thx !<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;<br />
<br />
struct Dictionary {<br />
&nbsp; &nbsp; &nbsp;  string english;<br />
&nbsp; &nbsp; &nbsp;  string indonesia;<br />
&nbsp; &nbsp; &nbsp;  };<br />
&nbsp; &nbsp; &nbsp;  Dictionary *p;<br />
&nbsp; &nbsp; &nbsp;  Dictionary *q[99];<br />
<br />
void mainMenu();<br />
int hashing (string s);<br />
void&nbsp; addDef();<br />
void searchDef();<br />
void deleteDef();<br />
void createNode(string a, string b);<br />
int quit ();<br />
&nbsp; &nbsp;  <br />
int main ()<br />
{<br />
&nbsp; &nbsp; mainMenu ();<br />
}<br />
<br />
void mainMenu ()<br />
{<br />
&nbsp; &nbsp; int choice;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Welcome to Dictionary of English-Indonesia 2012(KIAMAT !)&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;What do You want to do ?&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;1. add Definition to Dictionary&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;2. Search for Definition&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;3. delete Definition&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;4. Quit&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Enter the number you want :&nbsp; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt;choice;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if( choice == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; int no;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; while ( no != 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addDef();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Do you want to continue ? (1. yes, 2. no)&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; no;<br />
&nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (choice == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; searchDef();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (choice == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; deleteDef();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if ( choice == 4 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; quit ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Input Invalid ! Enter between 1-4 !&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainMenu();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
void createNode (string a, string b)<br />
{<br />
&nbsp; &nbsp;  p = (Dictionary *)malloc(sizeof(Dictionary));<br />
&nbsp; &nbsp;  if (p!=NULL)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; p-&gt;english = a;<br />
&nbsp; &nbsp; &nbsp; &nbsp; p-&gt;indonesia = b;<br />
&nbsp; &nbsp;  }<br />
&nbsp; &nbsp;  else<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;Memory FULL&quot;;<br />
&nbsp; &nbsp;  }<br />
}<br />
&nbsp; &nbsp;  <br />
void addDef ()<br />
{<br />
&nbsp; &nbsp;  string a;<br />
&nbsp; &nbsp;  string b;<br />
&nbsp; &nbsp;  int hashVal;<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Enter Word in English :&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt;a;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Enter the transelation in Indonesia :&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt;b;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; createNode(a,b);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hashVal = hashing (p-&gt;english);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q[hashVal] = p;<br />
}<br />
<br />
int hashing (string s)<br />
{<br />
&nbsp; &nbsp; int total = 0;<br />
&nbsp; &nbsp; int z = 0;<br />
&nbsp; &nbsp; char cname [99];<br />
&nbsp; &nbsp; string temp = s;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; for ( int i = 0; i &lt;= 99; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; cname[i] =&nbsp; temp.at(i);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; for (int j = 0; j &lt;= 99; j++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; total = total + (int)cname[j];<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; z = total % 99;<br />
&nbsp; &nbsp; return z;<br />
}<br />
<br />
int quit ()<br />
{<br />
&nbsp; &nbsp; return 0;<br />
}<br />
<br />
void searchDef(){}<br />
void deleteDef(){}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>prominababy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241984.html</guid>
		</item>
		<item>
			<title>I want to convert MFC RichEdit(with bitmaps) to API RichEdit(with bitmaps)</title>
			<link>http://www.daniweb.com/forums/thread241977.html</link>
			<pubDate>Sat, 28 Nov 2009 08:37:32 GMT</pubDate>
			<description><![CDATA[Hello Everybody, 
I m working on a IRC Chat application project. I would like to know how to insert hte bitmap into the chat window. I have got a few code snippets in MFC & its working perfectly in MFC. But i cant convert it into Win32. Can anybody pls help me in this regard. 
 
 
  <div...]]></description>
			<content:encoded><![CDATA[<div>Hello Everybody,<br />
I m working on a IRC Chat application project. I would like to know how to insert hte bitmap into the chat window. I have got a few code snippets in MFC &amp; its working perfectly in MFC. But i cant convert it into Win32. Can anybody pls help me in this regard.<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">// Four variables<br />
IRichEditOle *m_pRichEditOle;<br />
LPOLEOBJECT m_lpObject;<br />
LPSTORAGE m_lpStorage;<br />
LPOLECLIENTSITE m_lpClientSite; <br />
<br />
void CRichEditDlg::OnButton1() <br />
{<br />
// TODO: Add your control notification handler code here<br />
CreateFromFile(&quot;E:\\VC++\\RichEdit\\confused.bmp&quot;);<br />
REOBJECT reobject;<br />
ZeroMemory(&amp;reobject, sizeof(REOBJECT));<br />
reobject.cbStruct = sizeof(REOBJECT);<br />
<br />
CLSID clsid;<br />
SCODE sc = m_lpObject-&gt;GetUserClassID(&amp;clsid);<br />
if (sc != S_OK)<br />
AfxThrowOleException(sc);<br />
<br />
reobject.clsid = clsid;<br />
reobject.cp = REO_CP_SELECTION;<br />
reobject.dvaspect = DVASPECT_CONTENT;<br />
reobject.dwFlags = REO_RESIZABLE | REO_BELOWBASELINE;<br />
reobject.dwUser = 0;<br />
reobject.poleobj = m_lpObject;<br />
<br />
ASSERT(m_lpClientSite != NULL);<br />
reobject.polesite = m_lpClientSite;<br />
<br />
ASSERT(m_lpStorage != NULL);<br />
reobject.pstg = m_lpStorage;<br />
<br />
SIZEL sizel;<br />
sizel.cx = sizel.cy = 0;<br />
reobject.sizel = sizel; <br />
<br />
HWND hWndRT = (HWND)m_RchEditControl.GetHwnd();<br />
::SendMessage(hWndRT, EM_SETSEL, 0, -1);<br />
DWORD dwStart, dwEnd;<br />
::SendMessage(hWndRT, EM_GETSEL, (WPARAM)&amp;dwStart, (LPARAM)&amp;dwEnd);<br />
::SendMessage(hWndRT, EM_SETSEL, dwEnd+1, dwEnd+1); <br />
CString strCr = &quot;\r\n&quot;;<br />
m_RchEditControl.SetSelText((LPCTSTR)strCr); <br />
m_pRichEditOle-&gt;InsertObject(&amp;reobject); <br />
::SendMessage(hWndRT, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0); <br />
if (m_lpObject)<br />
{<br />
m_lpObject-&gt;Release();<br />
m_lpObject = NULL;<br />
}<br />
if (m_lpStorage)<br />
{<br />
m_lpStorage-&gt;Release();<br />
m_lpStorage = NULL;<br />
}<br />
if (m_lpClientSite)<br />
{<br />
m_lpClientSite-&gt;Release();<br />
m_lpClientSite = NULL;<br />
} <br />
}<br />
<br />
BOOL CRichEditDlg::CreateFromFile(LPCTSTR lpszFileName)<br />
{<br />
USES_CONVERSION;<br />
<br />
ASSERT_VALID(this);<br />
ASSERT(m_lpObject == NULL); // one time only<br />
<br />
ASSERT(m_lpStorage == NULL);<br />
ASSERT(m_lpClientSite == NULL);<br />
LPLOCKBYTES lpLockBytes = NULL;<br />
CLSID clsid = CLSID_NULL;<br />
OLERENDER render = OLERENDER_DRAW;<br />
CLIPFORMAT cfFormat = 0;<br />
LPFORMATETC lpFormatEtc = NULL;<br />
<br />
SCODE sc;<br />
<br />
sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &amp;lpLockBytes);<br />
if (sc != S_OK)<br />
AfxThrowOleException(sc);<br />
ASSERT(lpLockBytes != NULL);<br />
<br />
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,<br />
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &amp;m_lpStorage);<br />
if (sc != S_OK)<br />
{<br />
VERIFY(lpLockBytes-&gt;Release() == 0);<br />
lpLockBytes = NULL;<br />
AfxThrowOleException(sc);<br />
}<br />
ASSERT(m_lpStorage != NULL);<br />
<br />
// fill in FORMATETC struct<br />
FORMATETC formatEtc;<br />
lpFormatEtc = &amp;formatEtc;<br />
lpFormatEtc-&gt;cfFormat = cfFormat;<br />
lpFormatEtc-&gt;ptd = NULL;<br />
lpFormatEtc-&gt;dwAspect = DVASPECT_CONTENT;<br />
lpFormatEtc-&gt;lindex = -1;<br />
lpFormatEtc-&gt;tymed = TYMED_NULL;<br />
<br />
// attempt to create the object<br />
m_pRichEditOle-&gt;GetClientSite(&amp;m_lpClientSite);<br />
<br />
sc = ::OleCreateFromFile(clsid, T2COLE(lpszFileName),<br />
IID_IUnknown, OLERENDER_DRAW, lpFormatEtc, m_lpClientSite, m_lpStorage,<br />
(void**)&amp;m_lpObject);<br />
if (sc != S_OK)<br />
AfxThrowOleException(sc);<br />
<br />
// m_lpObject is currently an IUnknown, convert to IOleObject<br />
if (m_lpObject != NULL)<br />
{<br />
LPUNKNOWN lpUnk = m_lpObject;<br />
lpUnk-&gt;QueryInterface(IID_IOleObject, (void**)&amp;m_lpObject);<br />
lpUnk-&gt;Release();<br />
if (m_lpObject == NULL)<br />
AfxThrowOleException(E_OUTOFMEMORY);<br />
}<br />
<br />
// all items are &quot;contained&quot; -- this makes our reference to this object<br />
// weak -- which is needed for links to embedding silent update.<br />
OleSetContainedObject(m_lpObject, TRUE);<br />
<br />
ASSERT_VALID(this);<br />
return TRUE;<br />
}<br />
<br />
void CRichEditDlg::OnDestroy() <br />
{<br />
CDialog::OnDestroy();<br />
<br />
// TODO: Add your message handler code here<br />
if (m_pRichEditOle)<br />
{<br />
m_pRichEditOle-&gt;Release();<br />
m_pRichEditOle = NULL;<br />
} <br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>lashatt2</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241977.html</guid>
		</item>
		<item>
			<title>I want to convert MFC RichEdit to API RichEdit</title>
			<link>http://www.daniweb.com/forums/thread241975.html</link>
			<pubDate>Sat, 28 Nov 2009 08:36:04 GMT</pubDate>
			<description><![CDATA[Hello Everybody, 
I m working on a IRC Chat application project. I would like to know how to insert hte bitmap into the chat window. I have got a few code snippets in MFC & its working perfectly in MFC. But i cant convert it into Win32. Can anybody pls help me in this regard. 
 
 
  <div...]]></description>
			<content:encoded><![CDATA[<div>Hello Everybody,<br />
I m working on a IRC Chat application project. I would like to know how to insert hte bitmap into the chat window. I have got a few code snippets in MFC &amp; its working perfectly in MFC. But i cant convert it into Win32. Can anybody pls help me in this regard.<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">// Four variables<br />
IRichEditOle *m_pRichEditOle;<br />
LPOLEOBJECT m_lpObject;<br />
LPSTORAGE m_lpStorage;<br />
LPOLECLIENTSITE m_lpClientSite; <br />
<br />
void CRichEditDlg::OnButton1() <br />
{<br />
// TODO: Add your control notification handler code here<br />
CreateFromFile(&quot;E:\\VC++\\RichEdit\\confused.bmp&quot;);<br />
REOBJECT reobject;<br />
ZeroMemory(&amp;reobject, sizeof(REOBJECT));<br />
reobject.cbStruct = sizeof(REOBJECT);<br />
<br />
CLSID clsid;<br />
SCODE sc = m_lpObject-&gt;GetUserClassID(&amp;clsid);<br />
if (sc != S_OK)<br />
AfxThrowOleException(sc);<br />
<br />
reobject.clsid = clsid;<br />
reobject.cp = REO_CP_SELECTION;<br />
reobject.dvaspect = DVASPECT_CONTENT;<br />
reobject.dwFlags = REO_RESIZABLE | REO_BELOWBASELINE;<br />
reobject.dwUser = 0;<br />
reobject.poleobj = m_lpObject;<br />
<br />
ASSERT(m_lpClientSite != NULL);<br />
reobject.polesite = m_lpClientSite;<br />
<br />
ASSERT(m_lpStorage != NULL);<br />
reobject.pstg = m_lpStorage;<br />
<br />
SIZEL sizel;<br />
sizel.cx = sizel.cy = 0;<br />
reobject.sizel = sizel; <br />
<br />
HWND hWndRT = (HWND)m_RchEditControl.GetHwnd();<br />
::SendMessage(hWndRT, EM_SETSEL, 0, -1);<br />
DWORD dwStart, dwEnd;<br />
::SendMessage(hWndRT, EM_GETSEL, (WPARAM)&amp;dwStart, (LPARAM)&amp;dwEnd);<br />
::SendMessage(hWndRT, EM_SETSEL, dwEnd+1, dwEnd+1); <br />
CString strCr = &quot;\r\n&quot;;<br />
m_RchEditControl.SetSelText((LPCTSTR)strCr); <br />
m_pRichEditOle-&gt;InsertObject(&amp;reobject); <br />
::SendMessage(hWndRT, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0); <br />
if (m_lpObject)<br />
{<br />
m_lpObject-&gt;Release();<br />
m_lpObject = NULL;<br />
}<br />
if (m_lpStorage)<br />
{<br />
m_lpStorage-&gt;Release();<br />
m_lpStorage = NULL;<br />
}<br />
if (m_lpClientSite)<br />
{<br />
m_lpClientSite-&gt;Release();<br />
m_lpClientSite = NULL;<br />
} <br />
}<br />
<br />
BOOL CRichEditDlg::CreateFromFile(LPCTSTR lpszFileName)<br />
{<br />
USES_CONVERSION;<br />
<br />
ASSERT_VALID(this);<br />
ASSERT(m_lpObject == NULL); // one time only<br />
<br />
ASSERT(m_lpStorage == NULL);<br />
ASSERT(m_lpClientSite == NULL);<br />
LPLOCKBYTES lpLockBytes = NULL;<br />
CLSID clsid = CLSID_NULL;<br />
OLERENDER render = OLERENDER_DRAW;<br />
CLIPFORMAT cfFormat = 0;<br />
LPFORMATETC lpFormatEtc = NULL;<br />
<br />
SCODE sc;<br />
<br />
sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &amp;lpLockBytes);<br />
if (sc != S_OK)<br />
AfxThrowOleException(sc);<br />
ASSERT(lpLockBytes != NULL);<br />
<br />
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,<br />
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &amp;m_lpStorage);<br />
if (sc != S_OK)<br />
{<br />
VERIFY(lpLockBytes-&gt;Release() == 0);<br />
lpLockBytes = NULL;<br />
AfxThrowOleException(sc);<br />
}<br />
ASSERT(m_lpStorage != NULL);<br />
<br />
// fill in FORMATETC struct<br />
FORMATETC formatEtc;<br />
lpFormatEtc = &amp;formatEtc;<br />
lpFormatEtc-&gt;cfFormat = cfFormat;<br />
lpFormatEtc-&gt;ptd = NULL;<br />
lpFormatEtc-&gt;dwAspect = DVASPECT_CONTENT;<br />
lpFormatEtc-&gt;lindex = -1;<br />
lpFormatEtc-&gt;tymed = TYMED_NULL;<br />
<br />
// attempt to create the object<br />
m_pRichEditOle-&gt;GetClientSite(&amp;m_lpClientSite);<br />
<br />
sc = ::OleCreateFromFile(clsid, T2COLE(lpszFileName),<br />
IID_IUnknown, OLERENDER_DRAW, lpFormatEtc, m_lpClientSite, m_lpStorage,<br />
(void**)&amp;m_lpObject);<br />
if (sc != S_OK)<br />
AfxThrowOleException(sc);<br />
<br />
// m_lpObject is currently an IUnknown, convert to IOleObject<br />
if (m_lpObject != NULL)<br />
{<br />
LPUNKNOWN lpUnk = m_lpObject;<br />
lpUnk-&gt;QueryInterface(IID_IOleObject, (void**)&amp;m_lpObject);<br />
lpUnk-&gt;Release();<br />
if (m_lpObject == NULL)<br />
AfxThrowOleException(E_OUTOFMEMORY);<br />
}<br />
<br />
// all items are &quot;contained&quot; -- this makes our reference to this object<br />
// weak -- which is needed for links to embedding silent update.<br />
OleSetContainedObject(m_lpObject, TRUE);<br />
<br />
ASSERT_VALID(this);<br />
return TRUE;<br />
}<br />
<br />
void CRichEditDlg::OnDestroy() <br />
{<br />
CDialog::OnDestroy();<br />
<br />
// TODO: Add your message handler code here<br />
if (m_pRichEditOle)<br />
{<br />
m_pRichEditOle-&gt;Release();<br />
m_pRichEditOle = NULL;<br />
} <br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>lashatt2</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241975.html</guid>
		</item>
		<item>
			<title>Hello Everybody,  I m working on a IRC Chat application project. I would like to know</title>
			<link>http://www.daniweb.com/forums/thread241973.html</link>
			<pubDate>Sat, 28 Nov 2009 08:33:34 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>C++ Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">// Four variables<br />
IRichEditOle *m_pRichEditOle;<br />
LPOLEOBJECT m_lpObject;<br />
LPSTORAGE m_lpStorage;<br />
LPOLECLIENTSITE m_lpClientSite; <br />
<br />
void CRichEditDlg::OnButton1() <br />
{<br />
// TODO: Add your control notification handler code here<br />
CreateFromFile(&quot;E:\\VC++\\RichEdit\\confused.bmp&quot;);<br />
REOBJECT reobject;<br />
ZeroMemory(&amp;reobject, sizeof(REOBJECT));<br />
reobject.cbStruct = sizeof(REOBJECT);<br />
<br />
CLSID clsid;<br />
SCODE sc = m_lpObject-&gt;GetUserClassID(&amp;clsid);<br />
if (sc != S_OK)<br />
AfxThrowOleException(sc);<br />
<br />
reobject.clsid = clsid;<br />
reobject.cp = REO_CP_SELECTION;<br />
reobject.dvaspect = DVASPECT_CONTENT;<br />
reobject.dwFlags = REO_RESIZABLE | REO_BELOWBASELINE;<br />
reobject.dwUser = 0;<br />
reobject.poleobj = m_lpObject;<br />
<br />
ASSERT(m_lpClientSite != NULL);<br />
reobject.polesite = m_lpClientSite;<br />
<br />
ASSERT(m_lpStorage != NULL);<br />
reobject.pstg = m_lpStorage;<br />
<br />
SIZEL sizel;<br />
sizel.cx = sizel.cy = 0;<br />
reobject.sizel = sizel; <br />
<br />
HWND hWndRT = (HWND)m_RchEditControl.GetHwnd();<br />
::SendMessage(hWndRT, EM_SETSEL, 0, -1);<br />
DWORD dwStart, dwEnd;<br />
::SendMessage(hWndRT, EM_GETSEL, (WPARAM)&amp;dwStart, (LPARAM)&amp;dwEnd);<br />
::SendMessage(hWndRT, EM_SETSEL, dwEnd+1, dwEnd+1); <br />
CString strCr = &quot;\r\n&quot;;<br />
m_RchEditControl.SetSelText((LPCTSTR)strCr); <br />
m_pRichEditOle-&gt;InsertObject(&amp;reobject); <br />
::SendMessage(hWndRT, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0); <br />
if (m_lpObject)<br />
{<br />
m_lpObject-&gt;Release();<br />
m_lpObject = NULL;<br />
}<br />
if (m_lpStorage)<br />
{<br />
m_lpStorage-&gt;Release();<br />
m_lpStorage = NULL;<br />
}<br />
if (m_lpClientSite)<br />
{<br />
m_lpClientSite-&gt;Release();<br />
m_lpClientSite = NULL;<br />
} <br />
}<br />
<br />
BOOL CRichEditDlg::CreateFromFile(LPCTSTR lpszFileName)<br />
{<br />
USES_CONVERSION;<br />
<br />
ASSERT_VALID(this);<br />
ASSERT(m_lpObject == NULL); // one time only<br />
<br />
ASSERT(m_lpStorage == NULL);<br />
ASSERT(m_lpClientSite == NULL);<br />
LPLOCKBYTES lpLockBytes = NULL;<br />
CLSID clsid = CLSID_NULL;<br />
OLERENDER render = OLERENDER_DRAW;<br />
CLIPFORMAT cfFormat = 0;<br />
LPFORMATETC lpFormatEtc = NULL;<br />
<br />
SCODE sc;<br />
<br />
sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &amp;lpLockBytes);<br />
if (sc != S_OK)<br />
AfxThrowOleException(sc);<br />
ASSERT(lpLockBytes != NULL);<br />
<br />
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,<br />
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &amp;m_lpStorage);<br />
if (sc != S_OK)<br />
{<br />
VERIFY(lpLockBytes-&gt;Release() == 0);<br />
lpLockBytes = NULL;<br />
AfxThrowOleException(sc);<br />
}<br />
ASSERT(m_lpStorage != NULL);<br />
<br />
// fill in FORMATETC struct<br />
FORMATETC formatEtc;<br />
lpFormatEtc = &amp;formatEtc;<br />
lpFormatEtc-&gt;cfFormat = cfFormat;<br />
lpFormatEtc-&gt;ptd = NULL;<br />
lpFormatEtc-&gt;dwAspect = DVASPECT_CONTENT;<br />
lpFormatEtc-&gt;lindex = -1;<br />
lpFormatEtc-&gt;tymed = TYMED_NULL;<br />
<br />
// attempt to create the object<br />
m_pRichEditOle-&gt;GetClientSite(&amp;m_lpClientSite);<br />
<br />
sc = ::OleCreateFromFile(clsid, T2COLE(lpszFileName),<br />
IID_IUnknown, OLERENDER_DRAW, lpFormatEtc, m_lpClientSite, m_lpStorage,<br />
(void**)&amp;m_lpObject);<br />
if (sc != S_OK)<br />
AfxThrowOleException(sc);<br />
<br />
// m_lpObject is currently an IUnknown, convert to IOleObject<br />
if (m_lpObject != NULL)<br />
{<br />
LPUNKNOWN lpUnk = m_lpObject;<br />
lpUnk-&gt;QueryInterface(IID_IOleObject, (void**)&amp;m_lpObject);<br />
lpUnk-&gt;Release();<br />
if (m_lpObject == NULL)<br />
AfxThrowOleException(E_OUTOFMEMORY);<br />
}<br />
<br />
// all items are &quot;contained&quot; -- this makes our reference to this object<br />
// weak -- which is needed for links to embedding silent update.<br />
OleSetContainedObject(m_lpObject, TRUE);<br />
<br />
ASSERT_VALID(this);<br />
return TRUE;<br />
}<br />
<br />
void CRichEditDlg::OnDestroy() <br />
{<br />
CDialog::OnDestroy();<br />
<br />
// TODO: Add your message handler code here<br />
if (m_pRichEditOle)<br />
{<br />
m_pRichEditOle-&gt;Release();<br />
m_pRichEditOle = NULL;<br />
} <br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>lashatt2</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241973.html</guid>
		</item>
		<item>
			<title>devcpp.hlp</title>
			<link>http://www.daniweb.com/forums/thread241966.html</link>
			<pubDate>Sat, 28 Nov 2009 07:59:51 GMT</pubDate>
			<description><![CDATA[I installed Dev-c++ 4.9.9.2 but "devcpp.HLP" file doesn't exist in HELP folder! 
Does anybody know where can I download it?]]></description>
			<content:encoded><![CDATA[<div>I installed Dev-c++ 4.9.9.2 but &quot;devcpp.HLP&quot; file doesn't exist in HELP folder!<br />
Does anybody know where can I download it?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>H-man</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241966.html</guid>
		</item>
		<item>
			<title>Reading data from text file - C++</title>
			<link>http://www.daniweb.com/forums/thread241957.html</link>
			<pubDate>Sat, 28 Nov 2009 06:45:07 GMT</pubDate>
			<description>Hi, could anybody please tell me what i am doing wrong in this program. 
 
The goal is to read the student name and grade from a text file and print it on the screen. 
 
This is what i have so far. by the way this is for a school project that is due this coming Monday.  The attached file is the...</description>
			<content:encoded><![CDATA[<div>Hi, could anybody please tell me what i am doing wrong in this program.<br />
<br />
The goal is to read the student name and grade from a text file and print it on the screen.<br />
<br />
This is what i have so far. by the way this is for a school project that is due this coming Monday.  The attached file is the input source.<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream&gt;<br />
#include&lt;fstream&gt;<br />
#include&lt;string&gt;<br />
using namespace std;<br />
<br />
//void calculateAverage();<br />
//int calculateGrade();<br />
//void updateFrequency();<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; const int size=10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int debug=size;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int test1[size], test2[size], test3[size], test4[size], test5[size];<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream infile;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0;i&lt;size;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test1[i]=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test2[i]=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test3[i]=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test4[i]=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test5[i]=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Reading from file ''input.txt''...&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; infile.open(&quot;input.txt&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(size==debug)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int i=0;i&lt;size;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; infile&gt;&gt;test1[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; infile&gt;&gt;test2[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; infile&gt;&gt;test3[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; infile&gt;&gt;test4[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; infile&gt;&gt;test5[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; debug--;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0;i&lt;size;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;test1[i]&lt;&lt;&quot; &quot;&lt;&lt;test2[i]&lt;&lt;&quot; &quot;&lt;&lt;test3[i]&lt;&lt;&quot; &quot;&lt;&lt;test4[i]&lt;&lt;&quot; &quot;&lt;&lt;test5[i]&lt;&lt;&quot; &quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; infile.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div>  <br /> <div style="padding:5px">     <fieldset class="fieldset"> <legend>Attached Files</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/txt.gif" alt="File Type: txt" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12753&amp;d=1259390615">input.txt</a> (235 Bytes)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>josey_matt</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241957.html</guid>
		</item>
		<item>
			<title>Visual c++ book recommendation</title>
			<link>http://www.daniweb.com/forums/thread241947.html</link>
			<pubDate>Sat, 28 Nov 2009 05:09:12 GMT</pubDate>
			<description>I wanted to get some opinions on a good visual c++ book to buy. I am intermediate level when it comes to  programming. I have already been through a class on C and almost done with my class on C++. So I want a book that is heavy on the actual visual part, I am not concerned about stacks, binary...</description>
			<content:encoded><![CDATA[<div>I wanted to get some opinions on a good visual c++ book to buy. I am intermediate level when it comes to  programming. I have already been through a class on C and almost done with my class on C++. So I want a book that is heavy on the actual visual part, I am not concerned about stacks, binary trees etc as I already know how those work. Any suggestions would be appreciated. <br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>pinsickle</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241947.html</guid>
		</item>
		<item>
			<title>Passing parameters to a method</title>
			<link>http://www.daniweb.com/forums/thread241941.html</link>
			<pubDate>Sat, 28 Nov 2009 03:55:18 GMT</pubDate>
			<description><![CDATA[Hi *, 
 
I have some doubts about passing parameters to a method of a class. I am not sure if it is a problem of my design of the app or a problem of the implementation, I mean C++ knowledge. 
 
I have a class called MatrixHandler : The idea is to manage a matrix simply-basic 
 
  <div...]]></description>
			<content:encoded><![CDATA[<div>Hi *,<br />
<br />
I have some doubts about passing parameters to a method of a class. I am not sure if it is a problem of my design of the app or a problem of the implementation, I mean C++ knowledge.<br />
<br />
I have a class called MatrixHandler : The idea is to manage a matrix simply-basic<br />
<br />
 <pre style="margin:20px; line-height:13px">MatrixHandler.h<br />
#ifndef MATRIXHANDLER_H<br />
#define MATRIXHANDLER_H<br />
<br />
using namespace std;<br />
<br />
class MatrixHandler<br />
{<br />
&nbsp; private:<br />
&nbsp; &nbsp; double **data;<br />
&nbsp; public:<br />
&nbsp; &nbsp; MatrixHandler() {}<br />
&nbsp; &nbsp; MatrixHandler(int rows, int cols);<br />
&nbsp; &nbsp; ~MatrixHandler();<br />
&nbsp; &nbsp; void setMatrixValue(int row, int col, double value);<br />
&nbsp; &nbsp; double getMatrixValue(int row, int col);<br />
};<br />
#endif</pre><br />
 <pre style="margin:20px; line-height:13px">MatrixHandler.cpp<br />
<br />
#include &lt;iostream&gt;<br />
<br />
#include &quot;MatrixHandler.h&quot;<br />
<br />
MatrixHandler::MatrixHandler(int rows, int cols)<br />
{<br />
&nbsp; data = new double*[rows];<br />
<br />
&nbsp; for (int i = 0;i&lt;rows;i++)<br />
&nbsp; &nbsp; data[i] = new double[cols];<br />
}<br />
<br />
MatrixHandler::~MatrixHandler()<br />
{<br />
&nbsp; delete[] data;<br />
}<br />
<br />
void MatrixHandler::setMatrixValue(int row, int col, double value)<br />
{<br />
&nbsp; data[row][col] = value;<br />
}<br />
<br />
double MatrixHandler::getMatrixValue(int row, int col)<br />
{<br />
&nbsp; return data[row][col];<br />
}</pre><br />
And a class called Instance : The idea is to read all .txt files of a directory and take each file and get the data an put it in a matrix which I want to use in my main program<br />
<br />
 <pre style="margin:20px; line-height:13px">Instance.h<br />
#ifndef INSTANCE_H<br />
#define INSTANCE_H<br />
<br />
#include &quot;MatrixHandler.h&quot;<br />
<br />
using namespace std;<br />
<br />
class Instance<br />
{<br />
&nbsp; private:<br />
&nbsp; &nbsp; int n;<br />
&nbsp; &nbsp; int m;<br />
&nbsp; public:<br />
&nbsp; &nbsp; Instance() { }<br />
&nbsp; &nbsp; vector&lt;string&gt; listFiles(string dir);<br />
&nbsp; &nbsp; void getNewInstance(string file);<br />
&nbsp; &nbsp; void setN(int number);<br />
&nbsp; &nbsp; void setM(int number);<br />
&nbsp; &nbsp; int getN();<br />
&nbsp; &nbsp; int getM();<br />
};<br />
<br />
#endif</pre><br />
 <pre style="margin:20px; line-height:13px">Instance.cpp<br />
<br />
#include &lt;sys/types.h&gt;<br />
#include &lt;dirent.h&gt;<br />
#include &lt;errno.h&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;string&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;istream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;sstream&gt;<br />
#include &lt;iomanip&gt;<br />
<br />
#include &quot;Instance.h&quot;<br />
#include &quot;MatrixHandler.h&quot;<br />
<br />
vector&lt;string&gt; Instance::listFiles(string dir)<br />
{<br />
&nbsp; vector&lt;string&gt; files = vector&lt;string&gt;();<br />
&nbsp; DIR *dp;<br />
&nbsp; struct dirent *dirp;<br />
&nbsp; string fileName;<br />
&nbsp; //string npos;<br />
<br />
&nbsp; // check if directory can be opened<br />
&nbsp; if((dp&nbsp; = opendir(dir.c_str())) == NULL) {<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Error(&quot; &lt;&lt; errno &lt;&lt; &quot;) opening &quot; &lt;&lt; dir &lt;&lt; endl;<br />
&nbsp; &nbsp; exit(-1);<br />
&nbsp; }<br />
<br />
&nbsp; // reading directory until there is no more filed to read<br />
&nbsp; // this includes . files and hide files such as .swp (VIM temporary<br />
&nbsp; // files)<br />
&nbsp; while ((dirp = readdir(dp)) != NULL) {<br />
&nbsp; &nbsp; fileName = string(dirp-&gt;d_name);<br />
&nbsp; &nbsp; // our interest are txt files only but not the &quot;best_values&quot; txt<br />
&nbsp; &nbsp; // files<br />
&nbsp; &nbsp; if ((fileName.substr(fileName.find_last_of(&quot;.&quot;) + 1) == &quot;txt&quot;) &amp;&amp; \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ((fileName.find(&quot;best_values&quot;)) == string::npos)) {<br />
&nbsp; &nbsp; &nbsp; files.push_back(fileName);<br />
&nbsp; &nbsp; }<br />
&nbsp; }<br />
<br />
&nbsp; closedir(dp);<br />
&nbsp; return files;<br />
}<br />
<br />
void Instance::getNewInstance(string fileName)<br />
{<br />
&nbsp; ifstream file(fileName.c_str()); // reading the file<br />
<br />
&nbsp; int from, to;<br />
&nbsp; double cost;<br />
<br />
&nbsp; if (file.is_open()) // Open file operation succees<br />
&nbsp; {<br />
&nbsp; &nbsp; file &gt;&gt; from &gt;&gt; to;<br />
&nbsp; &nbsp; setN(from);<br />
&nbsp; &nbsp; setM(to);<br />
&nbsp; &nbsp; MatrixHandler data(from,from);<br />
&nbsp; &nbsp; while (file &gt;&gt; from &gt;&gt; to &gt;&gt; cost)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; data.setMatrixValue(from,to,cost);<br />
&nbsp; &nbsp; &nbsp; data.setMatrixValue(to,from,cost);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; file.close();<br />
&nbsp; }<br />
&nbsp; else cout &lt;&lt; &quot;File&quot; &lt;&lt; fileName &lt;&lt; &quot;can not be opened&quot; &lt;&lt; endl;<br />
<br />
}<br />
<br />
void Instance::setN(int number)<br />
{<br />
&nbsp; n = number;<br />
}<br />
<br />
void Instance::setM(int number)<br />
{<br />
&nbsp; m = number;<br />
}<br />
<br />
int Instance::getN()<br />
{<br />
&nbsp; return n;<br />
}<br />
<br />
int Instance::getM()<br />
{<br />
&nbsp; return m;<br />
}</pre><br />
and of course my main program <br />
<br />
 <pre style="margin:20px; line-height:13px">MMDP_SA.cpp<br />
<br />
#include &lt;sys/types.h&gt;<br />
#include &lt;dirent.h&gt;<br />
#include &lt;errno.h&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;string&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
<br />
#include &quot;Instance.h&quot;<br />
#include &quot;MatrixHandler.h&quot;<br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Instance instances;<br />
&nbsp; &nbsp; &nbsp; &nbsp; string dir = string(&quot;.&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector&lt;string&gt; files = vector&lt;string&gt;();<br />
&nbsp; &nbsp; &nbsp; &nbsp; files = instances.listFiles(dir);<br />
&nbsp; &nbsp; &nbsp; &nbsp; MatrixHandler ss;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //for (unsigned int i = 0; i &lt; files.size();i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; for (unsigned int i = 0; i &lt; 1;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //cout &lt;&lt; files[i] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; instances.getNewInstance(files[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; ss.getMatrixValue(1,2) &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
I think (IMHO) this:<br />
<br />
I designed the matrix class keeping in mind that just its methods can modify (manipulate) the matrix.<br />
<br />
So trough matrix class methods the class Instance can set the values in the matrix but I can not figure out the best/correct way to work with the matrix in the main app :<br />
<br />
1.- One solution is to instance the class matrix in the main program and pass it to Instance methods to work with it<br />
<br />
2.- By other hand is possible to make the getNewInstance method of Instance class type of MatrixHandler.<br />
<br />
My point is that I am not sure whic is the best/correct way to solve this doubt. <br />
<br />
Does someone drop some ideas?..<br />
<br />
Thanks in advanced and best regards.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>fjrivash</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241941.html</guid>
		</item>
		<item>
			<title>Extracting data from a file</title>
			<link>http://www.daniweb.com/forums/thread241940.html</link>
			<pubDate>Sat, 28 Nov 2009 03:50:06 GMT</pubDate>
			<description><![CDATA[I wanna extract the data from the file so I can sort it out, add and delete files. How can I do it? My file contains a list of songs with the song name, artist and song duration. 
Here is what I have so far: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>I wanna extract the data from the file so I can sort it out, add and delete files. How can I do it? My file contains a list of songs with the song name, artist and song duration.<br />
Here is what I have so far:<br />
<br />
 <pre style="margin:20px; line-height:13px">//Nathaly Advincula<br />
//Song Assignment<br />
<br />
#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;string&gt;<br />
using namespace std;<br />
<br />
class Song<br />
{<br />
private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; string title;<br />
&nbsp; &nbsp; &nbsp; &nbsp; string artist;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double duration_sec;<br />
public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Defaul constructor<br />
&nbsp; &nbsp; &nbsp; &nbsp; Song ()<br />
&nbsp; &nbsp; &nbsp; &nbsp; { title= &quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; artist= &quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; duration_sec=99; next=0;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; //3 argument constructor<br />
&nbsp; &nbsp; &nbsp; &nbsp; Song (string st, string sa, double min)<br />
&nbsp; &nbsp; &nbsp; &nbsp; { title=st;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; artist=sa;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; duration_sec=min*60; next=0;}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; void setTitle (string st)<br />
&nbsp; &nbsp; &nbsp; &nbsp; { title=st; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; void setArtist(string sa)<br />
&nbsp; &nbsp; &nbsp; &nbsp; { artist=sa; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; void setDuration_sec ( double min)<br />
&nbsp; &nbsp; &nbsp; &nbsp; { duration_sec=min*60; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; string getTitle ()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {return title; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; string getArtist ()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {return artist; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; double getDuration_sec ()<br />
&nbsp; &nbsp; &nbsp; &nbsp; { return duration_sec; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; Song *next;<br />
};<br />
<br />
class SongList<br />
{<br />
private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Song *head;<br />
public: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  SongList()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  { head=NULL; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Song* getHead()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {&nbsp; return head;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //functions<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void insertSong (Song *);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void deleteSong (string);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  double songCount ();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  void printTitle_n_Duration(double);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void printSong_by_Artist(string);<br />
<br />
};<br />
<br />
void SongList::insertSong(Song *ptrAddTitle)<br />
{<br />
<br />
&nbsp;Song* nodePtr, *prevPtr;<br />
<br />
&nbsp;if(head == NULL || head-&gt;getTitle() &gt;= ptrAddTitle-&gt;getTitle())<br />
&nbsp;{<br />
&nbsp; if(head != NULL)<br />
&nbsp;  ptrAddTitle-&gt;next = head;<br />
&nbsp; <br />
&nbsp; head = ptrAddTitle;<br />
&nbsp; <br />
<br />
&nbsp;}<br />
&nbsp;else<br />
&nbsp;{<br />
&nbsp; prevPtr = head;<br />
&nbsp; nodePtr = head-&gt;next;<br />
&nbsp; //find point to insert<br />
&nbsp; while(nodePtr != NULL &amp;&amp; nodePtr-&gt;getTitle() &lt; ptrAddTitle-&gt;getTitle())<br />
&nbsp; {<br />
&nbsp;  prevPtr = nodePtr;<br />
&nbsp;  nodePtr = nodePtr-&gt;next;<br />
&nbsp; }<br />
<br />
&nbsp; prevPtr-&gt;next = ptrAddTitle;<br />
&nbsp; ptrAddTitle-&gt;next = nodePtr;<br />
<br />
&nbsp;}<br />
<br />
<br />
}<br />
<br />
<br />
void SongList::deleteSong(string title)<br />
{<br />
<br />
&nbsp;Song* nodePtr, *prevPtr;<br />
<br />
&nbsp;//if(head == NULL) is the same thing as<br />
&nbsp;if(!head)<br />
&nbsp; return;<br />
<br />
&nbsp;//is the first element the one 2 delete<br />
&nbsp;if(head-&gt;getTitle() == title)<br />
&nbsp;{<br />
<br />
&nbsp; nodePtr = head;<br />
&nbsp; head = head-&gt;next;<br />
&nbsp; delete nodePtr;<br />
&nbsp;}<br />
&nbsp;else<br />
&nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  nodePtr = head;<br />
&nbsp; while(nodePtr != NULL &amp;&amp; nodePtr-&gt;getTitle() != title)<br />
&nbsp; {<br />
&nbsp; prevPtr = nodePtr;<br />
&nbsp;  nodePtr = nodePtr-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; }<br />
<br />
&nbsp; //if(nodePtr != NULL) is the smae thing as<br />
&nbsp; if(nodePtr)<br />
&nbsp; {<br />
&nbsp;  prevPtr-&gt;next = nodePtr-&gt;next;<br />
&nbsp;  delete nodePtr;<br />
&nbsp; }<br />
<br />
<br />
&nbsp;}<br />
<br />
}<br />
<br />
//count the number of songs contained in the SongList&nbsp; (return the count)<br />
double SongList::songCount ()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  Song* nodePtr, *prevPtr;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  double total=0;<br />
<br />
&nbsp;//if(head == NULL) is the same thing as<br />
&nbsp;if(!head)<br />
&nbsp; return 0;<br />
<br />
&nbsp;else<br />
&nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  nodePtr = head;<br />
<br />
&nbsp; while(nodePtr != NULL )<br />
&nbsp; {<br />
&nbsp;  total++;<br />
&nbsp;  prevPtr = nodePtr;<br />
&nbsp;  nodePtr = nodePtr-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; }<br />
&nbsp;cout &lt;&lt;total&lt;&lt; endl;<br />
<br />
&nbsp;}<br />
<br />
return total;&nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
<br />
<br />
//Print the title and the duration of every song that is longer than the number of minutes passed in as an argument. <br />
void SongList::printTitle_n_Duration(double mins)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; double secs=mins*60;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Song* nodePtr, *prevPtr;<br />
<br />
&nbsp;//if(head == NULL) is the same thing as<br />
&nbsp;if(!head)<br />
&nbsp; return;<br />
<br />
&nbsp;else<br />
&nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  nodePtr = head;<br />
<br />
&nbsp;while(nodePtr != NULL)<br />
&nbsp; {if (nodePtr-&gt;getDuration_sec() &gt; secs)<br />
&nbsp;  cout &lt;&lt;&quot;Title: &quot;&lt;&lt;nodePtr-&gt;getTitle()&lt;&lt;&quot; Duration: &quot;&lt;&lt;nodePtr-&gt;getDuration_sec()&lt;&lt; endl;<br />
&nbsp;prevPtr = nodePtr;<br />
&nbsp;nodePtr = nodePtr-&gt;next; }<br />
<br />
&nbsp;}<br />
<br />
}<br />
<br />
//Print the title of every song in the list performed by a passed in artist as an argument<br />
void SongList::printSong_by_Artist(string sArtist)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Song* nodePtr, *prevPtr;<br />
<br />
&nbsp;//if(head == NULL) is the same thing as<br />
&nbsp;if(!head)<br />
&nbsp; return;<br />
<br />
&nbsp;else<br />
&nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  nodePtr = head;<br />
<br />
&nbsp;while(nodePtr != NULL)<br />
&nbsp; {if (nodePtr-&gt;getArtist() == sArtist)<br />
&nbsp;  cout &lt;&lt;&quot;Title: &quot;&lt;&lt;nodePtr-&gt;getTitle()&lt;&lt; endl;<br />
&nbsp;prevPtr = nodePtr;<br />
&nbsp;nodePtr = nodePtr-&gt;next; }<br />
<br />
&nbsp;}<br />
<br />
}<br />
<br />
<br />
void main()<br />
{<br />
<br />
&nbsp;ifstream reader;&nbsp; //don't forget to #include &lt;fstream&gt;<br />
&nbsp;char songName[101], songArtist[101];<br />
&nbsp;int songLength;<br />
<br />
&nbsp;//*** Change to the location where you downloaded<br />
&nbsp;reader.open(&quot;C:\\nathaly\\songs.txt&quot;);&nbsp; //open the appropriate file<br />
<br />
&nbsp;while(!reader.eof())<br />
&nbsp;{<br />
&nbsp; reader.getline(songName, 100, ',');&nbsp; //reads the name of the song into songName<br />
&nbsp; reader.getline(songArtist, 100, ',');&nbsp; //reads the artist of the song into songArtist<br />
&nbsp; reader &gt;&gt; songLength;<br />
&nbsp; reader.ignore();<br />
<br />
&nbsp;<br />
&nbsp; cout &lt;&lt; &quot;Song name:&quot; &lt;&lt; songName &lt;&lt; endl;<br />
&nbsp; cout &lt;&lt; &quot;Song artist:&quot; &lt;&lt; songArtist &lt;&lt; endl;<br />
&nbsp; cout &lt;&lt; &quot;Song duration:&quot; &lt;&lt; songLength &lt;&lt; endl;<br />
<br />
&nbsp;}<br />
&nbsp;<br />
<br />
&nbsp;SongList Ipod;<br />
&nbsp;Song *ptr;<br />
&nbsp;<br />
&nbsp;ptr=new Song(&quot;Photogragh&quot;, &quot;Nickelback&quot; , 3.45);<br />
&nbsp;<br />
&nbsp;Ipod.insertSong (ptr);<br />
<br />
&nbsp;ptr=new Song(&quot;Mr. Brightside&quot;, &quot;The Killers&quot; , 2.30);<br />
<br />
&nbsp;Ipod.insertSong (ptr);<br />
<br />
&nbsp; ptr=new Song(&quot;Kansas&quot;, &quot;The Killers&quot; , 4 );<br />
&nbsp;<br />
&nbsp;Ipod.insertSong (ptr);<br />
<br />
&nbsp;ptr=new Song(&quot;Adagio for Strings&quot;, &quot;Tiesto&quot; , 2.5);<br />
<br />
&nbsp;Ipod.insertSong (ptr);<br />
<br />
&nbsp;ptr=new Song(&quot;Turbulence&quot;, &quot;Tiesto&quot; , 2.2);<br />
&nbsp;<br />
&nbsp;Ipod.insertSong (ptr);<br />
&nbsp;<br />
&nbsp;ptr=new Song(&quot;Zebra&quot;, &quot;Nickelback&quot; , 3.45);<br />
&nbsp;<br />
&nbsp;Ipod.insertSong (ptr);<br />
<br />
&nbsp;Song* curr=NULL;<br />
<br />
&nbsp;curr = Ipod.getHead();<br />
<br />
&nbsp;cout&lt;&lt;&quot;INSERTED SONGS&quot;&lt;&lt;endl;<br />
<br />
&nbsp;while(curr != NULL) <br />
&nbsp;{<br />
&nbsp; cout &lt;&lt; &quot;Song Title:&quot; &lt;&lt; curr-&gt;getTitle() &lt;&lt;<br />
&nbsp;  &quot;&nbsp; &nbsp; artist &quot; &lt;&lt; curr-&gt;getArtist() &lt;&lt; &quot;&nbsp;  duration &quot; &lt;&lt; curr-&gt;getDuration_sec()&lt;&lt; endl;<br />
<br />
&nbsp; curr = curr-&gt;next;<br />
<br />
&nbsp;}<br />
&nbsp;string name2delete;<br />
&nbsp;cout&lt;&lt;&quot;WHAT SONG WOULD YOU LIKE TO DELETE?&quot;&lt;&lt;endl;<br />
&nbsp;cin&gt;&gt;name2delete;<br />
&nbsp;Ipod.deleteSong(name2delete);<br />
&nbsp;<br />
&nbsp;cout &lt;&lt; &quot;NOT DELETED ITEMS\n&quot;; <br />
<br />
&nbsp;curr = Ipod.getHead();<br />
<br />
&nbsp;while(curr != NULL)<br />
&nbsp;{<br />
&nbsp; cout &lt;&lt; &quot;TITLE: &quot; &lt;&lt; curr-&gt;getTitle() &lt;&lt;<br />
&nbsp;  &quot; ARTIST &quot; &lt;&lt; curr-&gt;getArtist() &lt;&lt;&nbsp;  &quot; DURATION &quot; &lt;&lt; curr-&gt;getDuration_sec() &lt;&lt; endl;<br />
<br />
&nbsp; curr = curr-&gt;next;<br />
<br />
&nbsp;}<br />
<br />
&nbsp; cout&lt;&lt;&quot;TOTAL OF SONGS&quot;&lt;&lt;endl;<br />
&nbsp;<br />
&nbsp; Ipod.songCount ();<br />
<br />
&nbsp; double durVal;<br />
&nbsp; cout&lt;&lt;&quot;PRINT SONGS LONGER THAN&quot;&lt;&lt;endl;<br />
&nbsp; cin&gt;&gt;durVal;<br />
&nbsp; <br />
&nbsp; Ipod.printTitle_n_Duration(durVal);<br />
<br />
&nbsp; string searchArtist;<br />
&nbsp; cout&lt;&lt;&quot;WHAT ARTIST WOULD YOU LIKE TO SEARCH?&quot;&lt;&lt;endl;<br />
&nbsp; cin&gt;&gt;searchArtist;<br />
&nbsp; Ipod.printSong_by_Artist(searchArtist);<br />
<br />
<br />
&nbsp;<br />
&nbsp;reader.close();&nbsp;  //close the file<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Samyx</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241940.html</guid>
		</item>
		<item>
			<title>Natural Mergesort logic issues</title>
			<link>http://www.daniweb.com/forums/thread241936.html</link>
			<pubDate>Sat, 28 Nov 2009 02:41:06 GMT</pubDate>
			<description><![CDATA[I'm having difficulties thinking through the logic of my natural mergesort program. I think I have the split working correctly, but my merge doesn't seem to be working at all, and the pseudocode in my book and what I've found so far on the web is fuzzy. 
This is a natural mergesort, not your...]]></description>
			<content:encoded><![CDATA[<div>I'm having difficulties thinking through the logic of my natural mergesort program. I think I have the split working correctly, but my merge doesn't seem to be working at all, and the pseudocode in my book and what I've found so far on the web is fuzzy.<br />
This is a natural mergesort, not your typical binary mergesort, in the sense that it needs to take into account &quot;sublists,&quot; or elements in the list which are increasing (i.e. already sorted).<br />
<br />
This is what I have so far. I suspect my problem is in the merge function.<br />
<br />
Any help you could render would be greatly appreciated! :)<br />
<br />
 <pre style="margin:20px; line-height:13px">/******************************************************************************<br />
* Program:<br />
*&nbsp; &nbsp; Assignment 18, Natural Mergesort Program<br />
* Summary:<br />
*&nbsp; &nbsp; Gets a filename from the command line, and reads in numbers, inserting<br />
*&nbsp; &nbsp; them at the beginning of a linked list. The program then sorts the list<br />
*&nbsp; &nbsp; with a natural mergesort, using the external sort algorithm. After<br />
*&nbsp; &nbsp; sorting, the list contents are displayed.<br />
******************************************************************************/<br />
#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;list&gt;<br />
using namespace std;<br />
<br />
///////////////////////////////////////////////////////////////////////////////<br />
// main<br />
///////////////////////////////////////////////////////////////////////////////<br />
<br />
/**** Prototypes used in main *****/<br />
list &lt; int &gt; buildList(string filename);<br />
void mergesort(list &lt; int &gt; &amp;myList);<br />
void split(list &lt; int &gt; &amp;myList, list &lt; int &gt; &amp;sublist1,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  list &lt; int &gt; &amp;sublist2);<br />
list &lt; int &gt; merge(list &lt; int &gt; &amp;sublist1, list &lt; int &gt; &amp;sublist2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int &amp;numSublists);<br />
void display(list &lt; int &gt; &amp;myList);<br />
<br />
/******************************************************************************<br />
* main<br />
* Desc:<br />
*&nbsp; &nbsp; Gets a filename from the command line, and reads in numbers, inserting<br />
*&nbsp; &nbsp; them at the beginning of a linked list. The program then sorts the list<br />
*&nbsp; &nbsp; with a natural mergesort, using the external sort algorithm. After<br />
*&nbsp; &nbsp; sorting, the list contents are displayed.<br />
******************************************************************************/<br />
int main(int argc, char* argv[])<br />
{<br />
&nbsp;  string filename;<br />
&nbsp;  //Check for proper usage<br />
&nbsp;  if (argc != 2)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Usage: &lt;executable&gt; &lt;data file&gt;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; exit(1);<br />
&nbsp;  }<br />
&nbsp;  else //input is good<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; filename = argv[argc - 1];<br />
&nbsp;  }<br />
<br />
&nbsp;  /* Populate a linked list with the numbers, perform a natural merge sort<br />
&nbsp; &nbsp; &nbsp; on the list, and display the sorted list */<br />
&nbsp;  list &lt; int &gt; numbers = buildList(filename);<br />
&nbsp;  mergesort(numbers);<br />
&nbsp;  display(numbers);<br />
<br />
&nbsp;  return 0;<br />
}<br />
<br />
/******************************************************************************<br />
* buildList<br />
* Desc: Reads in numbers from a file and populates a linked list with the<br />
*&nbsp; &nbsp; &nbsp;  numbers. The linked list is then returned from the function.<br />
* Input: string filename<br />
* Return: Linked list of integers from the file (myList)<br />
******************************************************************************/<br />
list &lt; int &gt; buildList(string filename)<br />
{<br />
&nbsp;  ifstream inStream;<br />
&nbsp;  list &lt; int &gt; myList;<br />
<br />
&nbsp;  //open file and check for success<br />
&nbsp;  inStream.open(filename.c_str());<br />
&nbsp;  if (inStream.fail()) //file failed to open<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unable to open file \&quot;&quot; &lt;&lt; filename<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;\&quot; in function buildList()\n&quot;;<br />
&nbsp; &nbsp; &nbsp; exit(1);<br />
&nbsp;  }<br />
&nbsp;  else //successfully opened file<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; int number; //numbers read in from file<br />
&nbsp; &nbsp; &nbsp; //push on all numbers from file onto vector<br />
&nbsp; &nbsp; &nbsp; while (inStream &gt;&gt; number)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  myList.push_front(number);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; inStream.close();<br />
&nbsp;  }<br />
&nbsp;  return myList;<br />
}<br />
<br />
/******************************************************************************<br />
* mergesort<br />
* Desc: Performs a natural merge sort, using the external sort algorithm, on<br />
*&nbsp; &nbsp; &nbsp;  a user-specified linked list.<br />
* Input: Linked list to be sorted (myList)<br />
* Big-O: O(n log2 n) &lt;worst case, average case&gt;<br />
******************************************************************************/<br />
void mergesort(list &lt; int &gt; &amp;myList)<br />
{<br />
&nbsp;  list &lt; int &gt; split1;<br />
&nbsp;  list &lt; int &gt; split2;<br />
&nbsp;  int numSublists = 0;<br />
&nbsp;  do //Do while numSublists is greater than 1 (We have more to sort)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; //split myList into two lists<br />
&nbsp; &nbsp; &nbsp; split(myList, split1, split2);<br />
&nbsp; &nbsp; &nbsp; //merge corresponding sublists in split1 and split2 back into myList.<br />
&nbsp; &nbsp; &nbsp; myList = merge(split1, split2, numSublists);<br />
&nbsp;  } while (numSublists &gt; 1);<br />
}<br />
<br />
void split(list &lt; int &gt; &amp;myList, list &lt; int &gt; &amp;split1,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  list &lt; int &gt; &amp;split2)<br />
{<br />
&nbsp;  split1.clear();<br />
&nbsp;  split2.clear();<br />
&nbsp;  list &lt; int &gt; *target = &amp;split1;<br />
&nbsp;  list &lt; int &gt; ::iterator listIter = myList.begin();<br />
&nbsp;  //split list F into lists F1 and F2 by copying natural sorted subfiles of F alternately to F1 and F2<br />
&nbsp;  //WHILE the end of F has not been reached:<br />
&nbsp;  int prev = *listIter;<br />
&nbsp;  target-&gt;push_back(prev);<br />
&nbsp;  ++listIter;<br />
&nbsp;  int current;<br />
&nbsp;  while (listIter != myList.end())<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; current = *listIter;<br />
&nbsp; &nbsp; &nbsp; //copy a sorted subfile of F into F1 as follows: repeatedly read an element of F and write it into F1 until the next element in F is smaller than this copied item or the end of F is reached.<br />
&nbsp; &nbsp; &nbsp; if (current &lt; prev &amp; listIter != myList.end())<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  //switch target<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if (target == &amp;split1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; target = &amp;split2;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp;  //If the end of F has not been reached, copy the next sorted subfile of F into F2 in a similar manner<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; target = &amp;split1;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; //write to target<br />
&nbsp; &nbsp; &nbsp; target-&gt;push_back(current);<br />
&nbsp; &nbsp; &nbsp; prev = current;<br />
&nbsp; &nbsp; &nbsp; ++listIter;<br />
&nbsp;  }<br />
}<br />
<br />
list &lt; int &gt; merge(list &lt; int &gt; &amp;split1, list &lt; int &gt; &amp;split2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int &amp;numSublists)<br />
{<br />
&nbsp;  list &lt; int &gt; myList; //our newly merged list<br />
&nbsp;  list &lt; int &gt; ::iterator iter1 = split1.begin(); //iterator for sublist1<br />
&nbsp;  list &lt; int &gt; ::iterator iter2 = split2.begin(); //iterator for sublist2<br />
&nbsp;  numSublists = 0; //reset numSublists for this list<br />
&nbsp;  //While we have not reached the end of either split1 or split2<br />
&nbsp;  int prev1 = *iter1;<br />
&nbsp;  int prev2 = *iter2;<br />
&nbsp;  ++iter1;<br />
&nbsp;  ++iter2;<br />
&nbsp;  int current1;<br />
&nbsp;  int current2;<br />
&nbsp;  while (iter1 != split1.end() &amp;&amp; iter2 != split2.end())<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; current1 = *iter1;<br />
&nbsp; &nbsp; &nbsp; current2 = *iter2;<br />
&nbsp; &nbsp; &nbsp; //WHILE no end of a sublist in F1 or in F2 has been reached<br />
&nbsp; &nbsp; &nbsp; while (current1 &gt; prev1 &amp;&amp; current2 &gt; prev2)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  //If the next element in F1 is less than the next element in F2<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if (current1 &gt; current2)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //then Copy the next element from F1 into F<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myList.push_back(*iter1);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //copy the next element from F2 into F<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myList.push_back(*iter2);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  prev1 = current1;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  prev2 = current2;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  ++iter1;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  ++iter2;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; //If the end of a subfile in F1 has been reached<br />
&nbsp; &nbsp; &nbsp; if (iter1 == split1.end())<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  //Then copy the rest of the corresponding subfile in F2 to F<br />
&nbsp; &nbsp; &nbsp; &nbsp;  while (current2 &gt; prev2 &amp;&amp; iter2 != split2.end())<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myList.push_back(current2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prev2 = current2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ++iter2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current2 = *iter2;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  //copy the rest of the corresponding subfile in F1 to F<br />
&nbsp; &nbsp; &nbsp; &nbsp;  while (current1 &gt; prev1 &amp;&amp; iter1 != split1.end())<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myList.push_back(current1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prev1 = current1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ++iter1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current1 = *iter1;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; prev1 = current1;<br />
&nbsp; &nbsp; &nbsp; prev2 = current2;<br />
&nbsp; &nbsp; &nbsp; ++iter1;<br />
&nbsp; &nbsp; &nbsp; ++iter2;<br />
&nbsp; &nbsp; &nbsp; //Increment numSubfiles by 1<br />
&nbsp; &nbsp; &nbsp; ++numSublists;<br />
&nbsp;  }<br />
&nbsp;  //Copy any subfiles remaining in F1 or F2 to F, incrementing numSubfiles by 1 for each<br />
&nbsp;  return myList;<br />
}<br />
<br />
/******************************************************************************<br />
* display<br />
* Desc: Displays the contents of a linked list.<br />
* Input: Linked list whose contents will be displayed (myList)<br />
******************************************************************************/<br />
void display(list &lt; int &gt; &amp;myList)<br />
{<br />
&nbsp;  list &lt; int &gt; ::iterator listIter = myList.begin();<br />
&nbsp;  while (listIter != myList.end())<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; *listIter &lt;&lt; ' ';<br />
&nbsp; &nbsp; &nbsp; ++listIter;<br />
&nbsp;  }<br />
&nbsp;  cout &lt;&lt; endl;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>wmsigler</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241936.html</guid>
		</item>
		<item>
			<title>.txt file to array.</title>
			<link>http://www.daniweb.com/forums/thread241935.html</link>
			<pubDate>Sat, 28 Nov 2009 02:32:41 GMT</pubDate>
			<description>Hey Guys, 
I have a text file that has numbers in it. And I need the program I am working on to search it as an array. How do I do that?</description>
			<content:encoded><![CDATA[<div>Hey Guys,<br />
I have a text file that has numbers in it. And I need the program I am working on to search it as an array. How do I do that?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>sabian4k</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241935.html</guid>
		</item>
		<item>
			<title>need help with my Average numbers program</title>
			<link>http://www.daniweb.com/forums/thread241933.html</link>
			<pubDate>Sat, 28 Nov 2009 02:23:16 GMT</pubDate>
			<description>Write a program that will ask the user for 10 numbers, store them in an array, print the array, and print the average of the numbers entered. 
 
You should: 
 
All steps should be pseudo-coded before actually going to the computer, and you will be required to submit the pseudo-code of your project...</description>
			<content:encoded><![CDATA[<div>Write a program that will ask the user for 10 numbers, store them in an array, print the array, and print the average of the numbers entered.<br />
<br />
You should:<br />
<br />
All steps should be pseudo-coded before actually going to the computer, and you will be required to submit the pseudo-code of your project (in a doc or txt file) as part of your submission.<br />
<br />
Write a function that prompts the user to enter 10 numbers, accepting double format, and return an array containing those numbers.<br />
Write a function to output the elements of the array in a nice format.<br />
Write a function which accepts the array as input and returns the average of the numbers in the array.<br />
Write a main program to effectively tie these functions together and solve the problem.<br />
Define at least two sets of test data and the expected results when the program will run using these sets as input. <br />
<br />
Here is what I have come up with so far....<br />
<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px"> #include &lt;iostream&gt;<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; int sum = 0;<br />
&nbsp; &nbsp; int average = 0;<br />
&nbsp; &nbsp; int array[10] = {1,2,3,4,5,6,7,8,9,10};<br />
&nbsp; &nbsp; for (int i = 0; i &lt; 10; ++i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; sum+=array[i];<br />
&nbsp; &nbsp; average = sum/10;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Average:&quot;&lt;&lt;average;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>gen84</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241933.html</guid>
		</item>
		<item>
			<title>HW HELP</title>
			<link>http://www.daniweb.com/forums/thread241924.html</link>
			<pubDate>Sat, 28 Nov 2009 01:06:04 GMT</pubDate>
			<description>Write a program that will ask the user for 10 numbers, store them in an array, print the array, and print the average of the numbers entered. 
 
You should: 
 
All steps should be pseudo-coded before actually going to the computer, and you will be required to submit the pseudo-code of your project...</description>
			<content:encoded><![CDATA[<div>Write a program that will ask the user for 10 numbers, store them in an array, print the array, and print the average of the numbers entered.<br />
<br />
You should:<br />
<br />
All steps should be pseudo-coded before actually going to the computer, and you will be required to submit the pseudo-code of your project (in a doc or txt file) as part of your submission.<br />
<br />
Write a function that prompts the user to enter 10 numbers, accepting double format, and return an array containing those numbers.<br />
Write a function to output the elements of the array in a nice format.<br />
Write a function which accepts the array as input and returns the average of the numbers in the array.<br />
Write a main program to effectively tie these functions together and solve the problem.<br />
Define at least two sets of test data and the expected results when the program will run using these sets as input. Include these test cases in your doc or txt file.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>gen84</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241924.html</guid>
		</item>
		<item>
			<title>Need help with my program...Kee getting errors</title>
			<link>http://www.daniweb.com/forums/thread241921.html</link>
			<pubDate>Sat, 28 Nov 2009 00:48:11 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>C++ Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">/****************************************************/<br />
/* File: Binomial Numbers.cpp */ <br />
/* */ <br />
/* Created by: Regine R Calinda */ <br />
/* Date: November 9, 2009 */ <br />
/* */ <br />
/* Program to compute binomial coefficients */ <br />
/* */ <br />
/* Inputs: (keyboard) */ <br />
/* Two positive integers (n &amp; k) */ <br />
/* */ <br />
/* Output: */ <br />
/* Corresponding binomial coefficient (nCk) */ <br />
/* */ <br />
/* Algorithm: see attached description */ <br />
/****************************************************/ <br />
<br />
#include &lt;iostream&gt; <br />
<br />
using namespace std ; <br />
<br />
int binomial(int n, int k) ; // function prototype <br />
int main()<br />
{<br />
int n, k ; // parameters for the binomial number<br />
int result ; <br />
<br />
cout &lt;&lt; endl ; <br />
<br />
// read in n &amp; k <br />
<br />
cout &lt;&lt; &quot;Enter n (positive integer) : &quot; ;<br />
cin &gt;&gt; n ; <br />
<br />
cout &lt;&lt; &quot;Enter k (positive integer) : &quot; ;<br />
cin &gt;&gt; k ; <br />
<br />
result = binomial (n,k) ; <br />
<br />
cout &lt;&lt; &quot;Binomial number &quot; &lt;&lt; n &lt;&lt; &quot;C&quot; &lt;&lt; k<br />
&lt;&lt; &quot; = &quot; &lt;&lt; result &lt;&lt; endl ; <br />
<br />
return (0) ;<br />
} // end main<br />
<br />
<br />
// ******************************************************** <br />
<br />
int binomial(int n, int k) <br />
<br />
/* Computes the binomial coefficient nCk */<br />
/* */<br />
/* Inputs: */<br />
/* n, k (integers)&nbsp; */<br />
/* */<br />
/* Output: */<br />
/* binomial coefficient nCk (integer) */ <br />
<br />
{<br />
int numerator, denominator ;<br />
int i ; // needed to compute numerator &amp; denominator <br />
<br />
if (n&lt;k) <br />
{<br />
return(0) ;<br />
}<br />
else<br />
{<br />
denominator = k ; <br />
<br />
for (i = 0&nbsp; ; i &lt;=&nbsp; ; i = i+1)<br />
denominator =&nbsp; n ;<br />
<br />
return (n) ;<br />
} // end if <br />
} // end function binomial</pre><br />
&gt;c:\users\genie\documents\visual studio 2008\projects\binomial numbers\binomial numbers\binomial numbers.cpp(71) : error C2059: syntax error : ';'<br />
<br />
1&gt;c:\users\genie\documents\visual studio 2008\projects\binomial numbers\binomial numbers\binomial numbers.cpp(71) : error C2143: syntax error : missing ';' before ')'<br />
<br />
1&gt;c:\users\genie\documents\visual studio 2008\projects\binomial numbers\binomial numbers\binomial numbers.cpp(71) : error C2143: syntax error : missing ';' before ')'<br />
<br />
1&gt;Build log was saved at &quot;file://c:\Users\genie\Documents\Visual Studio 2008\Projects\Binomial Numbers\Binomial Numbers\Debug\BuildLog.htm&quot;<br />
1&gt;Binomial Numbers - 3 error(s), 0 warning(s)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>gen84</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241921.html</guid>
		</item>
		<item>
			<title>Help Please!!!</title>
			<link>http://www.daniweb.com/forums/thread241916.html</link>
			<pubDate>Sat, 28 Nov 2009 00:36:41 GMT</pubDate>
			<description><![CDATA[I keep getting these errors. I'm so lost please help... fairly new to c++ programming. 
 
hashheader.h(8) : error C2144: syntax error : 'int' should be preceded by ';' 
 
hashheader.h(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
 
hashheader.h(14)...]]></description>
			<content:encoded><![CDATA[<div>I keep getting these errors. I'm so lost please help... fairly new to c++ programming.<br />
<br />
hashheader.h(8) : error C2144: syntax error : 'int' should be preceded by ';'<br />
<br />
hashheader.h(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int<br />
<br />
hashheader.h(14) : error C2061: syntax error : identifier 'string'<br />
<br />
hashheader.h(20) : error C2061: syntax error : identifier 'HashElement'<br />
<br />
hashheader.h(26) : error C2146: syntax error : missing ';' before identifier 'get'<br />
<br />
hashheader.h(26) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int<br />
<br />
hashheader.h(26) : error C2061: syntax error : identifier 'string'<br />
<br />
hashheader.h(26) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int<br />
<br />
hashheader.h(26) : warning C4183: 'get': missing return type; assumed to be a member function returning 'int'<br />
<br />
hashheader.h(36) : error C2146: syntax error : missing ';' before identifier 'words'<br />
<br />
hashheader.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int<br />
<br />
hashheader.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;cstring&gt;<br />
#include &lt;fstream&gt;<br />
#ifndef HASHTABLE<br />
#define HASHTABLE<br />
<br />
<br />
tyepdef int HashElement;<br />
<br />
class HashTable<br />
{<br />
public:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int hash(string word);<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* <br />
&nbsp; &nbsp; &nbsp; &nbsp; a function that determines an array index for key.<br />
&nbsp; &nbsp; &nbsp; &nbsp; the function sums the values of the ascii codes for each letter<br />
&nbsp; &nbsp; &nbsp; &nbsp; in the key and returns the sum to the caller.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */<br />
&nbsp; &nbsp; &nbsp; &nbsp; void put(HashElement entry);<br />
&nbsp; &nbsp; &nbsp; &nbsp; /*<br />
&nbsp; &nbsp; &nbsp; &nbsp; places the entry into a hash table<br />
&nbsp; &nbsp; &nbsp; &nbsp; it uses linear probing to resolve collisions.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; HashElement get(string key);<br />
&nbsp; &nbsp; &nbsp; &nbsp; /*returns the element in the hash table that has the key 'string key'. <br />
&nbsp; &nbsp; &nbsp; &nbsp; the record is retrieved by hashing.<br />
&nbsp; &nbsp; */<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; void display (int lowerbound, int upperbound);<br />
&nbsp; &nbsp; &nbsp; &nbsp; //prints entries between lower bound and upper bound<br />
<br />
private:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; string words[16000];<br />
&nbsp; &nbsp; &nbsp; &nbsp; //array of 16000 strings<br />
<br />
};<br />
<br />
#endif</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>chalgi26</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241916.html</guid>
		</item>
		<item>
			<title>getline is having problem with spaces</title>
			<link>http://www.daniweb.com/forums/thread241879.html</link>
			<pubDate>Fri, 27 Nov 2009 20:36:36 GMT</pubDate>
			<description>The problem in this is that the program accepts a string with spaces *only for the first input* and not for the rest of the inputs. It seems that getline only works for the first input.  
How can you make the vector store string with spaces (as elements of the vector)? 
Eg: 
Enter string:Harry...</description>
			<content:encoded><![CDATA[<div>The problem in this is that the program accepts a string with spaces <span style="font-weight:bold">only for the first input</span> and not for the rest of the inputs. It seems that getline only works for the first input. <br />
How can you make the vector store string with spaces (as elements of the vector)?<br />
Eg:<br />
Enter string:Harry Potter<br />
Anymore(y/n):y<br />
Enter string:<br />
Anymore(y/n):y        //The cursor comes here directly when y is input<br />
Enter string:<br />
Anymore(y/n):Superman  //When you try to enter a string<br />
//The program abruptly ends<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream&gt;<br />
#include&lt;vector&gt;<br />
using namespace std;<br />
int main()<br />
{<br />
&nbsp; &nbsp; string n;<br />
&nbsp; &nbsp; vector&lt;string&gt; a;<br />
&nbsp; &nbsp; char ch='y';<br />
&nbsp; &nbsp; vector&lt;string&gt;::iterator i;<br />
&nbsp; &nbsp; while(ch=='y'||ch=='Y')<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;\nEnter string:&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  getline(cin,n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  a.push_back(n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;\nAnymore(y/n):&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cin&gt;&gt;ch;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; for(i=a.begin();i!=a.end();++i)<br />
&nbsp; &nbsp; cout&lt;&lt;*i&lt;&lt;&quot;\n&quot;;<br />
&nbsp; &nbsp; cin.get();<br />
&nbsp; &nbsp; cin.get();<br />
&nbsp; &nbsp; return 1;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>sreejithbabu</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241879.html</guid>
		</item>
		<item>
			<title>creating program check some rules</title>
			<link>http://www.daniweb.com/forums/thread241877.html</link>
			<pubDate>Fri, 27 Nov 2009 20:29:23 GMT</pubDate>
			<description><![CDATA[hi there  
 
i have problem making this program its rely difficult on me 
 
the idea of the program is (1) To parse a string to determine if it conforms to the grammar  & 
 (2) To generate strings conforming to the grammar 
 
this is the grammars 
we must start with S  that's  aR 
T = terminals]]></description>
			<content:encoded><![CDATA[<div>hi there <br />
<br />
i have problem making this program its rely difficult on me<br />
<br />
the idea of the program is (1) To parse a string to determine if it conforms to the grammar  &amp;<br />
 (2) To generate strings conforming to the grammar<br />
<br />
this is the grammars<br />
we must start with S  that's  aR<br />
T = terminals <br />
N= non terminals <br />
S= star symbol<br />
P= rules<br />
<br />
<br />
T = {a, b, c, d} <br />
N = {S,R,N,P}<br />
S = S <br />
P = { <br />
        S &gt;&gt; a R <br />
        R &gt;&gt;b N    <br />
        N &gt;&gt; c P   <br />
        P &gt;&gt; b N    <br />
        P &gt;&gt; d   <br />
   } <br />
<br />
<br />
thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>lovely ari</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241877.html</guid>
		</item>
		<item>
			<title>Code Snippet Fast Animation with the Windows GDI</title>
			<link>http://www.daniweb.com/code/snippet241875.html</link>
			<pubDate>Fri, 27 Nov 2009 20:15:57 GMT</pubDate>
			<description><![CDATA[Quite a while ago, I made *this* (http://www.daniweb.com/code/snippet217147.html) snippet. This code is basically the same, except that it adds animation. 
 
This method of blitting is very fast assuming you don't use a surface that's too large. On a 500 x 500 surface, I managed 350fps using only...]]></description>
			<content:encoded><![CDATA[<div>Quite a while ago, I made <a rel="nofollow" class="t" href="http://www.daniweb.com/code/snippet217147.html" target="_blank"><span style="font-weight:bold">this</span></a> snippet. This code is basically the same, except that it adds animation.<br />
<br />
This method of blitting is very fast assuming you don't use a surface that's too large. On a 500 x 500 surface, I managed 350fps using only 0-1% of the cpu. This snippet may appear much slower because of the amount of CPU it's applying to each pixel, but the blitting itself is very fast. Also, don't forget that an average game will only redraw parts of the window that need redrawing, this redraws the whole surface every time.<br />
<br />
So, as long as you know what you're doing, Windows GDI isn't actually that slow :icon_lol:<br />
<br />
<span style="font-weight:bold">Attached executable:<br />
<a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12743" target="_blank">Attachment 12743</a><br />
<br />
Preview Image:<br />
<a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12744" target="_blank">Attachment 12744</a></span><br />
<br />
<span style="font-style:italic">edit: Running in Debug may reduce speed by a lot, set it as Release.</span></div>  <br /> <div style="padding:5px">    <fieldset class="fieldset"> <legend>Attached Images</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/png.gif" alt="File Type: png" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12744&amp;d=1259352832" target="_blank">prev.png</a> (135.8 KB)</td> </tr> </table> </fieldset>   <fieldset class="fieldset"> <legend>Attached Files</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/zip.gif" alt="File Type: zip" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12743&amp;d=1259352692">GDI Animation.zip</a> (32.3 KB)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>William Hemsworth</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241875.html</guid>
		</item>
		<item>
			<title>I started this Tic-tac-toe program...</title>
			<link>http://www.daniweb.com/forums/thread241874.html</link>
			<pubDate>Fri, 27 Nov 2009 20:07:42 GMT</pubDate>
			<description><![CDATA[But now can't finish it.. I can't figure out how to make the board display after every turn. Can anyone help? 
#include <iostream> 
using namespace std; 
void showBoard (char t[3][3]);  
 
int main () 
{ 
	char player; 
	char t[3][3] = {{'1', '2', '3'}, {'4', '5', '6'}, {'7', '8', '9'}}; 
	int...]]></description>
			<content:encoded><![CDATA[<div>But now can't finish it.. I can't figure out how to make the board display after every turn. Can anyone help?<br />
#include &lt;iostream&gt;<br />
using namespace std;<br />
void showBoard (char t[3][3]); <br />
<br />
int main ()<br />
{<br />
	char player;<br />
	char t[3][3] = {{'1', '2', '3'}, {'4', '5', '6'}, {'7', '8', '9'}};<br />
	int place = 0;<br />
<br />
	for (int i = 0; i &lt; 9; i++)<br />
	{<br />
		if ( i%2 == 0)<br />
	{ cout &lt;&lt; &quot;Place X (1-9): &quot;; player = 'X';}<br />
	else<br />
	{ cout &lt;&lt; &quot;Place O (1-9): &quot;; player = 'O';}<br />
<br />
	cin &gt;&gt; place;<br />
<br />
	}<br />
switch (place)<br />
<br />
{ case 1: t[0][0] = player;<br />
	break;<br />
  case 2: t[0][1] = player;<br />
    break;<br />
  case 3: t[0][2] = player;<br />
    break;<br />
  case 4: t[1][0] = player;<br />
	break;<br />
  case 5: t[1][1] = player;<br />
    break;<br />
  case 6: t[1][2] = player;<br />
	break;<br />
  case 7: t[2][0] = player;<br />
	break;<br />
  case 8: t[2][1] = player;<br />
    break;<br />
  case 9: t[2][2] = player;<br />
	break;<br />
}<br />
<br />
  for (int i = 0; i &lt; 3; i++)<br />
	{ for (int j = 0; j &lt; 3; j++)<br />
	cout &lt;&lt; t[i][j];<br />
	cout &lt;&lt; endl;<br />
  }<br />
<br />
return 0;<br />
}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>mokia1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241874.html</guid>
		</item>
		<item>
			<title>CImg Instructions PLEASE</title>
			<link>http://www.daniweb.com/forums/thread241873.html</link>
			<pubDate>Fri, 27 Nov 2009 20:05:59 GMT</pubDate>
			<description><![CDATA[Hello, 
I am trying to use the CImg library to put images into C++, can someone help? I don't know how to use this program... 
 
PLZ HELP]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
I am trying to use the CImg library to put images into C++, can someone help? I don't know how to use this program...<br />
<br />
PLZ HELP</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bman214</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241873.html</guid>
		</item>
		<item>
			<title><![CDATA["ffmpeg" and Visual Studio 2008]]></title>
			<link>http://www.daniweb.com/forums/thread241867.html</link>
			<pubDate>Fri, 27 Nov 2009 19:47:15 GMT</pubDate>
			<description><![CDATA[This must be a frequently asked question, but I can't find the answer in the FAQ, or in the recent archive of this list, or by using 
google with the keywords I thought of. 
 
I would like to use libavcodec.dll and libavformat.dll in my Windows 
XP Visual C++ 2008 project.  However, I would prefer...]]></description>
			<content:encoded><![CDATA[<div>This must be a frequently asked question, but I can't find the answer in the FAQ, or in the recent archive of this list, or by using<br />
google with the keywords I thought of.<br />
<br />
I would like to use libavcodec.dll and libavformat.dll in my Windows<br />
XP Visual C++ 2008 project.  However, I would prefer not to download a whole new compiler environment and compile ffmpeg from sources, just to get the dlls.<br />
<br />
Is there anyplace I can find relatively recent precompiled dll's<br />
and a matching header file?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>AbsoluteCPP</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241867.html</guid>
		</item>
		<item>
			<title>Read last line of a textFile.</title>
			<link>http://www.daniweb.com/forums/thread241865.html</link>
			<pubDate>Fri, 27 Nov 2009 19:43:05 GMT</pubDate>
			<description>I have searched for a way before what the most effective way and in this case important the fastest way is to seek backwards in a file to read the very last line in a file. 
 
Like in this case I want to search from the end and backwards to get the whole line in a TextFile. 
Important to know is...</description>
			<content:encoded><![CDATA[<div>I have searched for a way before what the most effective way and in this case important the fastest way is to seek backwards in a file to read the very last line in a file.<br />
<br />
Like in this case I want to search from the end and backwards to get the whole line in a TextFile.<br />
Important to know is that this file also only can consist of one line.<br />
I am familiar to read a file with StreamReader and the lines can have different lengths.<br />
<br />
<span style="font-weight:bold">3 lines in a file:</span><br />
<br />
Abcdefg 1234<br />
Abcdefg 123555<br />
Abcdefg 12344</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Darth Vader</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241865.html</guid>
		</item>
		<item>
			<title>C++ Question Issue ( the if and else code)</title>
			<link>http://www.daniweb.com/forums/thread241861.html</link>
			<pubDate>Fri, 27 Nov 2009 19:24:40 GMT</pubDate>
			<description><![CDATA[I am trying to create a dictionary program, just for fun. I doubt I will ever get past twenty words. But this program has a problem. It always goes to the word, no matter what I type in, or press.  
Here is the source code: 
 
 
#include <iostream> 
 
using namespace std; 
 
int main(void) 
{]]></description>
			<content:encoded><![CDATA[<div>I am trying to create a dictionary program, just for fun. I doubt I will ever get past twenty words. But this program has a problem. It always goes to the word, no matter what I type in, or press. <br />
Here is the source code:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
<br />
int main(void)<br />
{<br />
<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Search! Enter in a word that you would like to find the definition.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;If we can have it, we'll give you all we have on it.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;&nbsp; &nbsp; (Note: You must spell your word correctly.)&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Now press a key to start the program!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; string start;<br />
&nbsp; &nbsp; getline(cin, start);<br />
&nbsp; &nbsp; if (start == &quot;dfhbghkdabdhadvahdvadjahdvjdhdhjdvhhjdvhjhjj&quot;)<br />
&nbsp; &nbsp; {goto start;}<br />
&nbsp; &nbsp; else {goto start;}<br />
&nbsp; &nbsp; start:<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Choose a&#91;nother&#93; word!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; string word;<br />
&nbsp; &nbsp; getline(cin, word);<br />
&nbsp; &nbsp; if (word == &quot;close&quot; or &quot;Close&quot; or &quot;CLOSE&quot;){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return 0;}<br />
&nbsp; &nbsp; if (word == &quot;C++&quot; or &quot;c++&quot; or &quot;C+&quot; or &quot;c+&quot; or &quot;C&quot; or &quot;c&quot;)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;\&quot;C++\&quot; or \&quot;C\&quot; &lt;noun&gt; A programing platform language that is very famous, though a bit messed up.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  goto start;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; else {cout &lt;&lt; &quot;This word does not currently exist. Please consider submitting it!&quot; &lt;&lt; endl;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  goto start;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>arithehun</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241861.html</guid>
		</item>
		<item>
			<title>Pseudo code?</title>
			<link>http://www.daniweb.com/forums/thread241859.html</link>
			<pubDate>Fri, 27 Nov 2009 18:58:33 GMT</pubDate>
			<description><![CDATA[Hey, I need to create some pseudo code for a class and I dunno if I've done it right or not. Any help? 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox"...]]></description>
			<content:encoded><![CDATA[<div>Hey, I need to create some pseudo code for a class and I dunno if I've done it right or not. Any help?<br />
<br />
 <pre style="margin:20px; line-height:13px">Begin class Employee<br />
Initialise empty constructor Employee<br />
Initialise constructor Employee with parameters <br />
<br />
Define prototype for method getID(as integer)<br />
Define prototype for method getFirstName(as char array) <br />
Define prototype for method getLastName(as char array)<br />
Define prototype for method getAddress(as char array)<br />
Define prototype for method getAge(as intgeger)<br />
Define prototype for method getHours(as integer)<br />
Define prototype for method getPayRate(as float)<br />
<br />
Define prototype for method setID(as ineger)<br />
Define prototype for method setFirstName(as char array)<br />
Define prototype for method setLastName(as char array)<br />
Define prototype for method setAddress(as char array)<br />
Define prototype for method setAge(as integer)<br />
Define prototype for method setHours(as integer)<br />
Define prototype for method setPay(as float)<br />
<br />
<br />
set employee_id AS integer<br />
set employee_firstName AS character[255]<br />
set employee_lastName AS character[255]<br />
set employee_age AS integer<br />
set employee_hours AS integer<br />
set employee_pay AS float<br />
<br />
End class</pre><br />
 <pre style="margin:20px; line-height:13px">class Employee<br />
{<br />
&nbsp; &nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Employee();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Employee(int theID, char theName[], char theLastName[], char theAddress[], int theAge, int theHoursWorked, int thePayRate); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int getID();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  char* getFirstName();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  char* getLastName();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  char* getAddress();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int getAge();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int getHours();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  float getPayRate();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void setID(int theID);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void setFirstName(char theName[]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void setLastName(char theLastName[]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void setAddress(char theAddress[]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void setAge(int theAge);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void setHours(int theHoursWorked);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void setPay(int thePayRate);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int calculateTax();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  float calculateGrossPay();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int calculateDiscount();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  char setValues(bool isSalaried, float theSalary);<br />
&nbsp; &nbsp; &nbsp; protected:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int employee_id;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char employee_firstName[255];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char employee_lastName[255];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char employee_address[255];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int employee_age;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int employee_hours;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int employee_pay;<br />
};</pre><br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Phil++</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241859.html</guid>
		</item>
		<item>
			<title>Problem with eclipse IDE</title>
			<link>http://www.daniweb.com/forums/thread241848.html</link>
			<pubDate>Fri, 27 Nov 2009 18:04:10 GMT</pubDate>
			<description><![CDATA[Hi, 
When I want to run a program in eclipse, I get "Binary not found" error .  
I have MinGW in c: root and I have added C:/mingw/bin to environment path .]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
When I want to run a program in eclipse, I get &quot;Binary not found&quot; error . <br />
I have MinGW in c: root and I have added C:/mingw/bin to environment path .</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Behi Jon</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241848.html</guid>
		</item>
		<item>
			<title>Sorting an Array... pleeeeease help</title>
			<link>http://www.daniweb.com/forums/thread241845.html</link>
			<pubDate>Fri, 27 Nov 2009 17:56:14 GMT</pubDate>
			<description><![CDATA[This is the problem: 
Write a program that reads in an array of type int. Provide facility to either read  
this array from the key board or from a file, at the user's option. If the user chooses  
file input, the program should request a file name. You may assume that there are fewer than  
50...]]></description>
			<content:encoded><![CDATA[<div>This is the problem:<br />
Write a program that reads in an array of type int. Provide facility to either read <br />
this array from the key board or from a file, at the user's option. If the user chooses <br />
file input, the program should request a file name. You may assume that there are fewer than <br />
50 entries in the array. Your program determines how many entries there are. The output is <br />
to be a two-column list. The first column is a list of the distinct array elements; the <br />
second column is the count of the number of occurrences of each element. The list should be <br />
sorted on entries in the first column, largest to smallest.<br />
<br />
For the array<br />
<br />
-12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12<br />
<br />
the output should be<br />
<br />
N Count<br />
<br />
4 2<br />
<br />
3 3<br />
<br />
2 2<br />
<br />
1 4<br />
<br />
-1 1<br />
<br />
-12 4<br />
<br />
and this is what I have so far:<br />
<br />
#include &lt;iostream&gt;<br />
<br />
void fillArray(int a[], int SIZE, int&amp; lastElement);<br />
void sort(int a[], int lastElement);<br />
void swapValues(int&amp; v1, int&amp; v2);<br />
int indexSmallest(const int a[], int startIndex, int lastElement);<br />
void showFrequency (int a[], int SIZE);<br />
<br />
<br />
int main( )<br />
{<br />
	using namespace std;<br />
	const int SIZE = 50;<br />
	int arr[SIZE] = {0};<br />
	int lastElement; //the index<br />
	<br />
	cout &lt;&lt; &quot;Enter scores:\n&quot;;<br />
	fillArray (arr, SIZE, lastElement);<br />
	sort (arr, lastElement);<br />
	showFrequency (arr, lastElement);<br />
	return 0;<br />
}<br />
    <br />
<br />
<br />
void fillArray(int a[], int SIZE, int&amp; lastElement)<br />
{<br />
    using namespace std;<br />
	cout &lt;&lt; &quot;Enter up to &quot; &lt;&lt; SIZE &lt;&lt; &quot; nonnegative whole numbers.\n&quot;<br />
		 &lt;&lt; &quot;Mark the end of the list with a negative number.\n&quot;;<br />
	int next, index = 0;<br />
	cin &gt;&gt; next;<br />
	while ((next &gt;= 0) &amp;&amp; (index &lt; SIZE))<br />
	{<br />
		a[index] = next;<br />
		index++;<br />
		cin &gt;&gt; next;<br />
	}<br />
	lastElement = index;<br />
}<br />
void sort(int a[], int lastElement)<br />
{<br />
    int index_of_next_smallest;<br />
    for (int index = 0; index &lt; lastElement - 1; index++)<br />
    {<br />
        index_of_next_smallest =<br />
                     indexSmallest(a, index, lastElement);<br />
        swapValues(a[index], a[index_of_next_smallest]);<br />
      <br />
    }<br />
}<br />
<br />
<br />
void swapValues(int&amp; v1, int&amp; v2)<br />
{<br />
    int temp;<br />
    temp = v1;<br />
    v1 = v2;<br />
    v2 = temp;<br />
}<br />
<br />
<br />
int indexSmallest(const int a[], int startIndex, int lastElement)<br />
{<br />
    int min = a[startIndex],<br />
        index_of_min = startIndex;<br />
    for (int index = startIndex + 1; index &lt; lastElement; index++)<br />
        if (a[index] &lt; min)<br />
        {<br />
            min = a[index];<br />
            index_of_min = index;<br />
            //min is the smallest of a[start_index] through a[index]<br />
        }<br />
<br />
    return index_of_min;<br />
}<br />
<br />
void showFrequency (int a[], int SIZE)<br />
{ <br />
  using namespace std;<br />
  int prev = a[0], freq = 1; <br />
  cout &lt;&lt; &quot;Number        count \n&quot;;<br />
  cout &lt;&lt; a[0] &lt;&lt; &quot;   &quot;;<br />
  for (int i=1; i&lt;= SIZE; i++)<br />
  { if (prev == a[i])<br />
		freq++;<br />
  else <br />
  { cout &lt;&lt; freq;<br />
    cout &lt;&lt; a[i] &lt;&lt; &quot; &quot;;<br />
	freq = 1;<br />
	prev = a[i];<br />
  }<br />
  }<br />
  cout &lt;&lt; freq &lt;&lt; endl;<br />
}<br />
<br />
it's not coming out right... can anyone help?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>mokia1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241845.html</guid>
		</item>
		<item>
			<title>Virus denies web connection</title>
			<link>http://www.daniweb.com/forums/thread241843.html</link>
			<pubDate>Fri, 27 Nov 2009 17:24:39 GMT</pubDate>
			<description><![CDATA[I am having my first virus on my wife's computer. A pop up AV Pro Security has sent us porno and says we can only get rid of it by buying their fix.  A scam of course.  I have looked on line and found many was to combat this, but they all say you have to download them into your computer.  How can I...]]></description>
			<content:encoded><![CDATA[<div>I am having my first virus on my wife's computer. A pop up AV Pro Security has sent us porno and says we can only get rid of it by buying their fix.  A scam of course.  I have looked on line and found many was to combat this, but they all say you have to download them into your computer.  How can I do this if the virus will not let me connect to the interenet??  Please help, wife in tears. <br />
<br />
Richard V</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Richard V</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241843.html</guid>
		</item>
		<item>
			<title>how to access the index of iterator in map</title>
			<link>http://www.daniweb.com/forums/thread241834.html</link>
			<pubDate>Fri, 27 Nov 2009 15:52:30 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I am trying to see to which key the iterator is pointing in a map. is there a way to do so. 
Also, would it be the fastest way to store unique keys in a map. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am trying to see to which key the iterator is pointing in a map. is there a way to do so.<br />
Also, would it be the fastest way to store unique keys in a map.<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; mapType::iterator it = cube.begin();<br />
&nbsp; &nbsp; &nbsp; &nbsp; mapType::iterator its = it;<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::advance(its,1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(; it!= cube.end(); ++it)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:Green">cout &lt;&lt; &quot;Inside it = &quot; &lt;&lt; (it) - cube.begin() &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Inside its = &quot; &lt;&lt; (its) - cube.begin() &lt;&lt; endl;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(; its!= cube.end(); ++its)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;its = &quot; &lt;&lt; (its) - cube.begin() &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vector&lt;int&gt;::const_iterator it1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vector&lt;int&gt;::const_iterator it3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( it1 = it-&gt;first.begin(), it3 = its-&gt;first.begin(); it1!= it-&gt;first.end(), it3!= its-&gt;first.end(); ++it1,++it3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //cout &lt;&lt; *it1 &lt;&lt; &quot; &quot; &lt;&lt; *it3 &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((*it1 == 0 &amp;&amp; *it3 == 1) || (*it1 == 1 &amp;&amp; *it3 == 0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(*it1 == *it3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempo.push_back(*it1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if((*it1 == 0 &amp;&amp; *it3 == 2) || (*it1 == 2 &amp;&amp; *it3 == 0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempo.push_back(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempo.push_back(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(cube.count(tempo) &lt;= 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cube[tempo].push_back(10);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</pre>	<br />
The code marked in green does not work.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>guest7</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241834.html</guid>
		</item>
		<item>
			<title>Linked List Update Problem</title>
			<link>http://www.daniweb.com/forums/thread241831.html</link>
			<pubDate>Fri, 27 Nov 2009 15:37:26 GMT</pubDate>
			<description><![CDATA[Hi, I'm trying to update an objects information within my linked list but for some reason after attempting to alter the data no changes appear to have taken place. As far as I am aware I'm not updating a copy of the object because I am finding the relevant object (and this does work) and then...]]></description>
			<content:encoded><![CDATA[<div>Hi, I'm trying to update an objects information within my linked list but for some reason after attempting to alter the data no changes appear to have taken place. As far as I am aware I'm not updating a copy of the object because I am finding the relevant object (and this does work) and then creating a pointer to the address of the found object and then updating it's contents. The exact same code works if I use a vector but not when I use my own linked list (which I need to implement because this is for an imporatant assignment).<br />
<br />
 <pre style="margin:20px; line-height:13px">bool Bank::withdraw(double amount, int index)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Account *a = &amp;theAccounts.at(index);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(a-&gt;getBalance() &gt;= amount)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a-&gt;withdraw(amount);//problem is here<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false;<br />
}</pre><br />
Above is  the code that should be withdrawing money from an account but when I check the data after this method is called it displays it's original value (before withdrawal). Debugging showed me that the calculations etc. were all performed which is why I feel that somehow I am still only updating a copy.<br />
<br />
I've attached my linked list files and also the bank files. Any help is greatly appreciated, I have an assignment deadline very soon :s</div>  <br /> <div style="padding:5px">     <fieldset class="fieldset"> <legend>Attached Files</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/h.gif" alt="File Type: h" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12737&amp;d=1259336115">Bank.h</a> (1,011 Bytes)</td> </tr><tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/h.gif" alt="File Type: h" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12739&amp;d=1259336167">myList.h</a> (866 Bytes)</td> </tr><tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/cpp.gif" alt="File Type: cpp" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12740&amp;d=1259336179">myList.cpp</a> (1.6 KB)</td> </tr><tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/cpp.gif" alt="File Type: cpp" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12741&amp;d=1259336232">Bank.cpp</a> (2.6 KB)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>caged_fire</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241831.html</guid>
		</item>
		<item>
			<title>How to make every word to be a single string?</title>
			<link>http://www.daniweb.com/forums/thread241830.html</link>
			<pubDate>Fri, 27 Nov 2009 15:34:50 GMT</pubDate>
			<description><![CDATA[I have a small problem with string. How can I make the output str to be every single string 
 
i.e: 
string str="You are a good writer"; 
to be: 
str1="you"; 
str2=“are"; 
str3="a"; 
str4="good"; 
str5="writer";]]></description>
			<content:encoded><![CDATA[<div>I have a small problem with string. How can I make the output str to be every single string<br />
<br />
i.e:<br />
string str=&quot;You are a good writer&quot;;<br />
to be:<br />
str1=&quot;you&quot;;<br />
str2=“are&quot;;<br />
str3=&quot;a&quot;;<br />
str4=&quot;good&quot;;<br />
str5=&quot;writer&quot;;<br />
//---------my_test_code,but not working yet.<br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
using namespace std;<br />
<br />
int main () <br />
{<br />
    string str;<br />
	getline(cin,str);<br />
	int  i;<br />
    string::iterator It = str.begin();<br />
    while ( It != str.end() )<br />
    {<br />
    	if (*It == ' ' )<br />
    		*It = '\n';<br />
		<br />
		cout &lt;&lt;*It++;		<br />
    }<br />
    cout &lt;&lt; endl;<br />
    return 0;<br />
}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>qk00001</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241830.html</guid>
		</item>
		<item>
			<title>Having problem with reading string.</title>
			<link>http://www.daniweb.com/forums/thread241827.html</link>
			<pubDate>Fri, 27 Nov 2009 15:18:36 GMT</pubDate>
			<description>Hi, I am trying to let a string(a sentance) to be red into mysql.but I only can do it within one word, how can I do more? 
this is my code: 
//---------------------------------- 
sql::Driver *driver; 
sql::Connection *con; 
sql::Statement *stmt; 
sql::ResultSet *res; 
driver =...</description>
			<content:encoded><![CDATA[<div>Hi, I am trying to let a string(a sentance) to be red into mysql.but I only can do it within one word, how can I do more?<br />
this is my code:<br />
//----------------------------------<br />
sql::Driver *driver;<br />
sql::Connection *con;<br />
sql::Statement *stmt;<br />
sql::ResultSet *res;<br />
driver = get_driver_instance();<br />
con = driver-&gt;connect(&quot;localhost&quot;, &quot;root&quot;, &quot;qwerty&quot;);<br />
con-&gt;setSchema(&quot;menagerie&quot;);<br />
stmt = con-&gt;createStatement();<br />
stmt-&gt;execute(&quot;set names \'GBK\'&quot;);<br />
cout &lt;&lt; &quot;Please enter: &quot;;<br />
getline(cin,str1);<br />
string::iterator It = str1.begin();<br />
<br />
    while ( It != str1.end() )<br />
    {<br />
            if (*It == ' ' )<br />
                    *It = ' ';<br />
                cout &lt;&lt;*It++;<br />
    }//========================will stop here no going down anymore.any ideas why.<br />
<br />
   res=stmt-&gt;executeQuery(&quot;select * from test2 where english='&quot;+str1+&quot;'&quot;);<br />
        while (res-&gt;next())<br />
{<br />
         cout&lt;&lt;&quot;Result: &quot;&lt;&lt;res-&gt;getString(2);<br />
  }<br />
  delete res;<br />
  delete stmt;<br />
  delete con;</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kent01981</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241827.html</guid>
		</item>
		<item>
			<title>repeat without array</title>
			<link>http://www.daniweb.com/forums/thread241816.html</link>
			<pubDate>Fri, 27 Nov 2009 14:22:20 GMT</pubDate>
			<description><![CDATA[lets say i had this 
 
 
 
int times' 
 
 
cout<<"enter times you want to repeat"; 
cin>>times;]]></description>
			<content:encoded><![CDATA[<div>lets say i had this<br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
int times'<br />
<br />
<br />
cout&lt;&lt;&quot;enter times you want to repeat&quot;;<br />
cin&gt;&gt;times;<br />
<br />
<br />
<br />
----&gt;&nbsp; <br />
cout&lt;&lt;&quot;Hello what age are you?&quot;;<br />
cin&gt;&gt;age;<br />
<br />
&nbsp; &lt;-------</pre><br />
<br />
how would i get it to repeat this section of codes the same amount as the user inputs?<br />
<br />
but make it that if he input repeat by 5 times, that each time you input an age, for the 5 times, that that age is make into a variable.<br />
<br />
<br />
example<br />
<br />
so if you click repeat 3 times and typed in 4,6 and 8<br />
that they would be each seprate varibles and be able to be used in further code<br />
<br />
<br />
also we can not use arrays.<br />
for loops we can only use<br />
for,while,do while loops<br />
among other basic things, but not arrays yet<br />
we can also use if, else, else if<br />
<br />
<br />
<br />
<br />
<br />
<br />
[code]</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>zendet</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241816.html</guid>
		</item>
		<item>
			<title>reading from second key in hash map</title>
			<link>http://www.daniweb.com/forums/thread241815.html</link>
			<pubDate>Fri, 27 Nov 2009 14:21:47 GMT</pubDate>
			<description>Hi, 
 
I am trying to read he has map starting from the second key instead of first key. I have two loops. One for loop iterator reads from the beginning of the has map. And the second for loop is trying to read from the second key of hash map.  Following is my code. There is a compile time error...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am trying to read he has map starting from the second key instead of first key. I have two loops. One for loop iterator reads from the beginning of the has map. And the second for loop is trying to read from the second key of hash map.  Following is my code. There is a compile time error at the colored portion in the code. <br />
<br />
An example of what i am trying to do:<br />
<br />
102<br />
110<br />
<br />
these are the two keys in my hash_map. I wish to combine these two keys to get a new key..so i have two for loops...first one to read the first key and the second one to read the second key. But it is not working.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;map&gt;<br />
#include &lt;vector&gt;<br />
&nbsp;<br />
using namespace std;<br />
typedef std::vector&lt;int&gt; v2;<br />
&nbsp;<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; typedef map&lt;v2,v2&gt; mapType;<br />
&nbsp; &nbsp; &nbsp; &nbsp; mapType cube;<br />
&nbsp; &nbsp; &nbsp; &nbsp; v2 v1; <br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  // let's declare some initial values to this map.<br />
&nbsp; &nbsp; &nbsp; &nbsp; v1.push_back(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; v1.push_back(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; v1.push_back(2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; cube.count(v1) &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(cube.count(v1) &lt;= 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; cube[v1].push_back(-2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cube[v1].push_back(3);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cube[v1].push_back(-4);<br />
&nbsp; &nbsp; &nbsp; &nbsp; v1.clear();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; v1.push_back(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; v1.push_back(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; v1.push_back(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; cube.count(v1) &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(cube.count(v1) &lt;= 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cube[v1].push_back(-2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cube[v1].push_back(-3);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cube[v1].push_back(-4);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; v1.clear();<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for(mapType::const_iterator it = cube.begin(); it!= cube.end(); it++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Key = &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( vector&lt;int&gt;::const_iterator it1 = it-&gt;first.begin(); it1!= it-&gt;first.end(); it1++ )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; *it1 &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl &lt;&lt; &quot;Value = &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( vector&lt;int&gt;::const_iterator it2 = it-&gt;second.begin(); it2!= it-&gt;second.end(); it2++ )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; *it2 &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::vector&lt;int&gt; tempo;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Try merging cubes here.<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(mapType::const_iterator it = cube.begin(); it!= cube.end(); it++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:Green">for(mapType::const_iterator its = cube.begin()+1; its!=<br />
cube.end(); its++)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Key = &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vector&lt;int&gt;::const_iterator it1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vector&lt;int&gt;::const_iterator it3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( it1 = it-&gt;first.begin(), it3 = its-&gt;first.begin(); it1!= it-&gt;first.end(), it3!= its-&gt;first.end(); it1++,it3++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; *it1 &lt;&lt; &quot; &quot; &lt;&lt; *it3 &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((*it1 == 0 &amp;&amp; *it3 == 1) || (*it1 == 1 &amp;&amp; *it3 == 0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(*it1 == *it3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempo.push_back(*it1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if((*it1 == 0 &amp;&amp; *it3 == 2) || (*it1 == 2 &amp;&amp; *it3 == 0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempo.push_back(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempo.push_back(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int k=0; k&lt;(int)tempo.size(); k++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&nbsp; &lt;&lt; tempo[k] &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; return 0;<br />
}</pre><br />
<br />
Any help is appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>guest7</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241815.html</guid>
		</item>
		<item>
			<title>Replace numbers to 0</title>
			<link>http://www.daniweb.com/forums/thread241812.html</link>
			<pubDate>Fri, 27 Nov 2009 14:10:35 GMT</pubDate>
			<description><![CDATA[Hi i'm new here ,and i'm still rookie at working with C++ Builder 6 
 
I have a task ,which i don't understand. My task is like that :.. 
Number array E (m,n) and i need to 
replace all the line and column even(oddly) numbers to 0(zero). 
 
Please im praying you all to show me how the exact formula...]]></description>
			<content:encoded><![CDATA[<div>Hi i'm new here ,and i'm still rookie at working with C++ Builder 6<br />
<br />
I have a task ,which i don't understand. My task is like that :..<br />
Number array E (m,n) and i need to<br />
replace all the line and column even(oddly) numbers to 0(zero).<br />
<br />
Please im praying you all to show me how the exact formula looks like.<br />
<br />
p.s. <br />
example of formula which is replacing first line of array to 0<br />
 <pre style="margin:20px; line-height:13px">void TForm1::Change()<br />
{<br />
&nbsp; for (int i = 0; i &lt; n; i++)<br />
&nbsp; &nbsp; for (int j = 0; j &lt; m; j++)<br />
&nbsp; &nbsp; &nbsp; if (A[i][j] % 2 == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[i][j] = 0;<br />
}</pre>but still i dont think i need this one :) waiting for your replies.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>grafas7</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241812.html</guid>
		</item>
		<item>
			<title>Moving a funtion to a new header inside the same class</title>
			<link>http://www.daniweb.com/forums/thread241805.html</link>
			<pubDate>Fri, 27 Nov 2009 14:01:27 GMT</pubDate>
			<description>This is my first post here, but I have been using the forum for many months and up untill now has been able to answer all my problems without me actually asking anything.  So thanks in advance for all the great work you guys do, you have been fantastic in the past. 
 
So, quick explanation.  I have...</description>
			<content:encoded><![CDATA[<div>This is my first post here, but I have been using the forum for many months and up untill now has been able to answer all my problems without me actually asking anything.  So thanks in advance for all the great work you guys do, you have been fantastic in the past.<br />
<br />
So, quick explanation.  I have a class, called particle, which containts the function called Assign.  Assign works perfectly where it is, but I want to move it.  So after a bit of googling it seems the best way to do this is to use &quot;::&quot;.<br />
<br />
So in a new header simply write   void particle::Assign(.....)<br />
<br />
However I am getting error C2653: 'particle' : is not a class or namespace name.  I do not know why, googling the error seems to suggest that the class &quot;particle&quot; does not exist.  It does, it is right there.  <br />
<br />
I suspect I am doing something daft, and is easy and obvious to fix, but a good hour of searching and reading various past threads has not helped.<br />
<br />
So, here is my code:<br />
<br />
First the relevant bits of particle class, called particle2.h:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;math.h&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &quot;threevector.h&quot;<br />
#include &quot;constants.h&quot;<br />
#include &quot;initial_line.h&quot;<br />
using namespace std;<br />
<br />
<br />
class particle<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; double x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double z;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double q;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double m;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double ux;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double uy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double uz;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double hux;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double huy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double huz;<br />
<br />
<br />
public:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; particle()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ux=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uy=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uz=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hux=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; huy=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; huz=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; particle(double x, double y, double z, double q, double m, double ux, double uy, double uz, double hux, double huy, double huz)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;x = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;y = y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;z = z;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;q = q;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //charge<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;m = m;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //mass<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;ux = ux;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //initial speed<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;uy = uy;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //initial speed<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;uz = uz;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //initial speed<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;hux = hux;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //previous half speed<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;huy = huy;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //previous half speed<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;huz = huz;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //previous half speed<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
void Assign(double, double, double, double, double, double, double, double, double, double, double);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double getx() const<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double gety() const<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double getz() const<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return z;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double getm()&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return m;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double getq()&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return q;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double getux()&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ux;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double getuy()&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return uy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double getuz()&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return uz;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double gethux()&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return hux;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double gethuy()&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return huy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double gethuz()&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return huz;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void setx(double x)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;x = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void sety(double y)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this-&gt;y = y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void setz(double z)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  this-&gt;z = z;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void setux(double ux)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  this-&gt;ux = ux;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void setuy(double uy)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  this-&gt;uy = uy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void setuz(double uz)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  this-&gt;uz = uz;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void sethux(double hux)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  this-&gt;hux = hux;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void sethuy(double huy)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  this-&gt;huy = huy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void sethuz(double huz)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  this-&gt;huz = huz;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void setq(double q)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  this-&gt;q = q;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void setm(double m)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  this-&gt;m = m;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</pre><br />
And here is the new header I have written, called initial_line.h:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &quot;particle2.h&quot;<br />
using namespace std;<br />
<br />
void particle::Assign(double x, double y, double z, double q, double m, double ux, double uy, double uz, double hux, double huy, double huz)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = x / b0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = y / b0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = z / b0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q = q / e;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m = m / me;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ux = ux / b0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uy = uy / b0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uz = uz / b0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hux = hux / b0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; huy = huy / b0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; huz = huz / b0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setx(x);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sety(y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setz(z);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setq(q);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setm(m);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setux(ux);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setuy(uy);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setuz(uz);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sethux(hux);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sethuy(huy);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sethuz(huz);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }</pre><br />
<br />
particle 2.h is the file that the particle class is in.<br />
<br />
So, the erros I get are <br />
<br />
h:\treecode\treecode\initial_line.h(4) : error C2653: 'particle' : is not a class or namespace name<br />
<br />
and then a load of errors for the set funtions eg.:  1&gt;h:\treecode\treecode\initial_line.h(18) : error C3861: 'setx': identifier not found<br />
<br />
<br />
I have tried various combinations of including and not including header files, and changing the names of the class and the funtion.<br />
<br />
So, I am at a loss.  It seems a simple enough concept that is just no working.  I am using C++ within VS2008 pro, version 9.  (Previous posts blamed errors in old compliers for problems)<br />
<br />
So, I would be very grateful of any help, and to anyone pointing out what I have done wrong.<br />
<br />
The funtion worked perfectly fine inside particle, and I assume all the errors involving the set funtions will go away onve it is properly linked with the particle class.<br />
<br />
Cheers<br />
<br />
Josh</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>joshjgordon</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241805.html</guid>
		</item>
		<item>
			<title>CRC cards - Need help</title>
			<link>http://www.daniweb.com/forums/thread241794.html</link>
			<pubDate>Fri, 27 Nov 2009 12:58:59 GMT</pubDate>
			<description><![CDATA[Hey there, please could you tell me if the CRC cards that I've created for my classes are alright please? 
 
There are 4 classes: 
 
Employee 
Manager 
Game 
Platform 
 
Manager inherits from Employee]]></description>
			<content:encoded><![CDATA[<div>Hey there, please could you tell me if the CRC cards that I've created for my classes are alright please?<br />
<br />
There are 4 classes:<br />
<br />
Employee<br />
Manager<br />
Game<br />
Platform<br />
<br />
Manager inherits from Employee<br />
Game assocates with Platform<br />
<br />
Employee + Game are super classes<br />
<br />
Thanks :)<br />
<br />
P.S please find document attactched.</div>  <br /> <div style="padding:5px">     <fieldset class="fieldset"> <legend>Attached Files</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/doc.gif" alt="File Type: doc" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12736&amp;d=1259326731">CRC cards.doc</a> (37.5 KB)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Phil++</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241794.html</guid>
		</item>
		<item>
			<title>Registry Edit to change NIC Speed</title>
			<link>http://www.daniweb.com/forums/thread241791.html</link>
			<pubDate>Fri, 27 Nov 2009 12:51:19 GMT</pubDate>
			<description>I am trying to change the NIC speed through the registry.. But my problem is that I dont fully understand the command RegSetValueEx. I have checked the Internet up and down for some good examples but have fallen short.. I am tring to set the default value for the NIOC speed to be 0 (Auto). Here is...</description>
			<content:encoded><![CDATA[<div>I am trying to change the NIC speed through the registry.. But my problem is that I dont fully understand the command RegSetValueEx. I have checked the Internet up and down for some good examples but have fallen short.. I am tring to set the default value for the NIOC speed to be 0 (Auto). Here is what I have for that part..<br />
<br />
 <pre style="margin:20px; line-height:13px">LPTSTR lptstrRegSubKey;<br />
LPCTSTR Caption2 = &quot;Speed Change Successfull!&quot;;<br />
HKEY hKey;<br />
<br />
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, &quot;SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\0001\\Ndi\\Params\\*SpeedDuplex\\enum&quot;, 0, KEY_SET_VALUE, &amp;hKey) == ERROR_SUCCESS)<br />
{<br />
&nbsp; &nbsp; lptstrRegSubKey = &quot;SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\0001\\Ndi\\Params\\*SpeedDuplex\\default&quot;;<br />
&nbsp; &nbsp; RegCloseKey (hKey);<br />
}<br />
<br />
if (RegSetValueEx(HKEY_LOCAL_MACHINE, lptstrRegSubKey, 0, REG_DWORD,&nbsp;  (PBYTE) 0, sizeof(0))==ERROR_SUCCESS)<br />
{<br />
&nbsp; &nbsp;  MessageBox(NULL, &quot;NIC Speed was changed to Auto..&quot;, Caption2,MB_OK);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>BruenorBH</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241791.html</guid>
		</item>
		<item>
			<title>2D array task</title>
			<link>http://www.daniweb.com/forums/thread241773.html</link>
			<pubDate>Fri, 27 Nov 2009 11:04:23 GMT</pubDate>
			<description><![CDATA[Hello! 
I am new one here. Firstly I would like to say that I'm really poor in english, so be patient with me.. 
 
In the school we had a new task.  So let me explain:  we have a 2d array with numbers.. like this: 
                                                  0 1 2 4 5 6 
                     ...]]></description>
			<content:encoded><![CDATA[<div>Hello!<br />
I am new one here. Firstly I would like to say that I'm really poor in english, so be patient with me..<br />
<br />
In the school we had a new task.  So let me explain:  we have a 2d array with numbers.. like this:<br />
                                                  0 1 2 4 5 6<br />
                                                  1 3 4 5 6 7<br />
                                                  3 4 7 8 9 4<br />
                                                  9 8 7 6 5 2<br />
now, we give the target. For example index 2 4. (in this case is number 9 on that place) . Then I need to find cheaper way from index 0 0 to target on index 2 4 (always for one step) ... So in this case the program should go like that: 0, 1, 2, 4, 5, 9 (if we look numbers), or indexes( 0 0, 0 1, 0 2, 1 3, and finally 2 4). Then we need to find cheaper way back from target on index 2 4 to index 0 0 (on different way(we can not use the same places we had before)).. So the way back should be like that: 9, 8, 4, 3, 0(if we look numbers), or 2 4, 2 3, 1 2, 1 1 and 0 0(if we look indexes).<br />
<br />
Any help will be appreciated.<br />
<br />
ps: Like I sad, we speak different language here.. Because of that, I'm terrible with english language (I understand it very well, but I can not write it,  because we have different expression here). I apologize for this.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>mikesr</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241773.html</guid>
		</item>
		<item>
			<title>Project, need help</title>
			<link>http://www.daniweb.com/forums/thread241772.html</link>
			<pubDate>Fri, 27 Nov 2009 11:03:51 GMT</pubDate>
			<description>Hello, im doing a project and need some help. 
 
my project is have to make a program for 5 judges. at the start the first thing asked is how many competitors are there. 
 
then it asks the first judge what hes gives for the first competitior, then what the second judge gives him and so on. 
 
then...</description>
			<content:encoded><![CDATA[<div>Hello, im doing a project and need some help.<br />
<br />
my project is have to make a program for 5 judges. at the start the first thing asked is how many competitors are there.<br />
<br />
then it asks the first judge what hes gives for the first competitior, then what the second judge gives him and so on.<br />
<br />
then it goes on to the next competitior until they are all done.<br />
<br />
the scores from the judges can only be from 0.0 to 6.0, and they are a float.<br />
<br />
also the program cannot end unless it is told so, so end program Y/N and if n it will ask that again. if N then it will close.<br />
<br />
The five scores for each judge must be averaged after their five results. so i remove the highest and lowest and then muliply the other three by 3.<br />
<br />
my main problem is that i can do the program for 1 competitor, but if i repeat that for as many competitors for the amount that the user puts in how would i make it that they make sperate varibales and not get mixed up?<br />
<br />
heres what i have so far and its working.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream.h&gt;<br />
#include&lt;conio.h&gt;<br />
<br />
int main()<br />
{<br />
<br />
float judge1high, judge1secondhigh, judge1thirdhigh, judge1forthhigh, judge1low, judge1average; <br />
float judge2high, judge2secondhigh, judge2thirdhigh, judge2forthhigh, judge2low, judge2average; <br />
float judge3high, judge3secondhigh, judge3thirdhigh, judge3forthhigh, judge3low, judge3average; <br />
float judge4high, judge4secondhigh, judge4thirdhigh, judge4forthhigh, judge4low, judge4average;<br />
float judge5high, judge5secondhigh, judge5thirdhigh, judge5forthhigh, judge5low, judge5average;<br />
float total;<br />
<br />
cout&lt;&lt;&quot;\n\n\t\t\t\t==================&quot;;<br />
cout&lt;&lt;&quot;\n\n\t\t\t\tOLYMPIC GAMES 2012&quot;;<br />
cout&lt;&lt;&quot;\n\n\t\t\t\t==================&quot;;<br />
<br />
<br />
//Judge 1 <br />
<br />
cout&lt;&lt;&quot;\n\n\t\t\tJudge 1 enter highest score to lowest score: \n\n&quot;;<br />
cin&gt;&gt;judge1high&gt;&gt;judge1secondhigh&gt;&gt;judge1thirdhigh&gt;&gt;judge1forthhigh&gt;&gt;judge1low;<br />
<br />
<br />
<br />
<br />
judge1average=(judge1secondhigh+judge1thirdhigh+judge1forthhigh)/3.0; <br />
<br />
cout&lt;&lt;&quot;\n\n\t\t\tThe average for judge 1 is: &quot;&lt;&lt;judge1average;<br />
<br />
//judge 2 <br />
cout&lt;&lt;&quot;\n\n\t\t\tJudge 2 enter highest score to lowest score: \n\n&quot;;<br />
cin&gt;&gt;judge2high&gt;&gt;judge2secondhigh&gt;&gt;judge2thirdhigh&gt;&gt;judge2forthhigh&gt;&gt;judge2low;<br />
<br />
judge2average=(judge2secondhigh+judge2thirdhigh+judge2forthhigh)/3.0; <br />
<br />
cout&lt;&lt;&quot;\n\n\t\t\tThe average for judge 2 is: &quot;&lt;&lt;judge2average; <br />
<br />
//judge 3<br />
cout&lt;&lt;&quot;\n\n\t\t\tJudge 3 enter highest score to lowest score: \n\n&quot;;<br />
cin&gt;&gt;judge3high&gt;&gt;judge3secondhigh&gt;&gt;judge3thirdhigh&gt;&gt;judge3forthhigh&gt;&gt;judge3low;<br />
<br />
judge3average=(judge3secondhigh+judge3thirdhigh+judge3forthhigh)/3.0; <br />
<br />
cout&lt;&lt;&quot;\n\n\t\t\tThe average for judge 3 is: &quot;&lt;&lt;judge3average;<br />
<br />
//Judge 4<br />
cout&lt;&lt;&quot;\n\n\t\t\tJudge 4 enter highest score to lowest score: \n\n&quot;;<br />
cin&gt;&gt;judge4high&gt;&gt;judge4secondhigh&gt;&gt;judge4thirdhigh&gt;&gt;judge4forthhigh&gt;&gt;judge4low;<br />
<br />
judge4average=(judge4secondhigh+judge4thirdhigh+judge4forthhigh)/3.0; <br />
<br />
cout&lt;&lt;&quot;\n\n\t\t\tThe average for judge 4 is: &quot;&lt;&lt;judge4average;<br />
<br />
//judge 5<br />
<br />
cout&lt;&lt;&quot;\n\n\t\t\tJudge 5 enter highest score to lowest score: \n\n&quot;;<br />
cin&gt;&gt;judge5high&gt;&gt;judge5secondhigh&gt;&gt;judge5thirdhigh&gt;&gt;judge5forthhigh&gt;&gt;judge5low;<br />
<br />
judge5average=(judge5secondhigh+judge5thirdhigh+judge5forthhigh)/3.0; <br />
<br />
cout&lt;&lt;&quot;\n\n\t\t\tThe average for judge 5 is: &quot;&lt;&lt;judge5average;<br />
<br />
total=(judge1average+judge2average+judge3average+judge4average+judge5average); <br />
<br />
cout&lt;&lt;&quot;\n\n\n\n\n\t\tThe total for this competitor is &quot;&lt;&lt;total;<br />
<br />
cout&lt;&lt;&quot;\n\n\n\n\n\t\t\t Press any key to continue&quot;; <br />
getch(); <br />
return 0; <br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>zendet</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241772.html</guid>
		</item>
		<item>
			<title>strcat questions</title>
			<link>http://www.daniweb.com/forums/thread241768.html</link>
			<pubDate>Fri, 27 Nov 2009 10:38:34 GMT</pubDate>
			<description><![CDATA['Learning CPP' programmer here. So, bear with me. 
 
First off : 
*STRCAT : * 
 
http://www.cplusplus.com/reference/clibrary/cstring/strcat/ 
 
When clearly the definition says : 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>'Learning CPP' programmer here. So, bear with me.<br />
<br />
First off :<br />
<span style="font-weight:bold">STRCAT : </span><br />
<br />
<a rel="nofollow" class="t" href="http://www.cplusplus.com/reference/clibrary/cstring/strcat/" target="_blank">http://www.cplusplus.com/reference/c...string/strcat/</a><br />
<br />
When clearly the definition says :<br />
 <pre style="margin:20px; line-height:13px">char * strcat ( char * destination, const char * source );</pre>Why'd they use char str[80] in the example???<br />
What types can be used?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>halluc1nati0n</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241768.html</guid>
		</item>
		<item>
			<title>Inheritance question</title>
			<link>http://www.daniweb.com/forums/thread241749.html</link>
			<pubDate>Fri, 27 Nov 2009 07:59:54 GMT</pubDate>
			<description>Hallo all, 
 
I have a question for implementing Inheritance in C++. I think I miss the concept of inheritance C++ somehow, because the second class can not take the parameter from the first class.. 
 
I need to use a class Carbol and Carbol2. In Carbol2, I need to add a particular extra function,...</description>
			<content:encoded><![CDATA[<div>Hallo all,<br />
<br />
I have a question for implementing Inheritance in C++. I think I miss the concept of inheritance C++ somehow, because the second class can not take the parameter from the first class..<br />
<br />
I need to use a class Carbol and Carbol2. In Carbol2, I need to add a particular extra function, and the rest is taking the parameters and methods from Carbol<br />
<br />
for Class Carbol, this is I am going to make<br />
 <pre style="margin:20px; line-height:13px">class Carbol<br />
{<br />
&nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; float radius,dtof,color,lofs;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Carbol(float r,float df,char c,float ls)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; radius=r;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dtof=df;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; color=c;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lofs=ls;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; void draw(Carbol a)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  the function that I want to implement with parameter passing<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
};</pre>and for the second class <br />
 <pre style="margin:20px; line-height:13px">class Carbol2:public Carbol<br />
{<br />
<br />
&nbsp; &nbsp; void gambar(Carbol2)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  another extra function that I want to add<br />
&nbsp;  }<br />
};</pre>and in int main<br />
 <pre style="margin:20px; line-height:13px">Carbol object(0.7,0,'y',1); <br />
&nbsp; &nbsp;  object.draw(object);<br />
&nbsp; &nbsp; Carbol2 ubjuct; <br />
&nbsp; &nbsp; ubjuct.gambar(0.6,2,'g',3); // this object should take the function from carbol, and add another function from carbol2</pre><br />
and the error when I compile this is <br />
<br />
<span style="font-style:italic">error: no matching function for call to ‘Carbol::Carbol()</span><br />
<br />
I think the problem is that I made a wrong implementation of Carbol2 (but I tried to make a lot of changes in the source code, it failed somehow).. From the error, it is said no matching function to call the first class, so does it mean that I have to change the structure for the first class? But if I don't use the second class, and only implement Carbol object(0.7,0,'y',1);    object.draw(object); in int main, it worked just fine.. Can anyone point out what mistake I have in this general concept? I apologize if you guys having a difficulty in understanding my English, but I hope you could get the general idea about the difficulty I am having..<br />
<br />
Cheerz,<br />
<br />
Reza</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>reza.adinata</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241749.html</guid>
		</item>
		<item>
			<title>Convert plain socket program to SSL, how to?</title>
			<link>http://www.daniweb.com/forums/thread241740.html</link>
			<pubDate>Fri, 27 Nov 2009 06:03:17 GMT</pubDate>
			<description><![CDATA[Hi, 
I've wrote a C++ program on windows (client-server) using gcc with following commands: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
I've wrote a C++ program on windows (client-server) using gcc with following commands:<br />
 <pre style="margin:20px; line-height:13px">SOCKET(...)<br />
bind(..)<br />
select(..)<br />
recv(..)<br />
send(..)<br />
close(..)</pre><br />
1- If I want to convert the application to use SSL3, what should I change? I need a general overview to get me started.<br />
<br />
2- If I want to convert the application to Linux platform, I guess I'll use:<br />
<br />
 <pre style="margin:20px; line-height:13px">read()<br />
write()</pre><br />
how to change that to use SSL3?<br />
<br />
Thanks alot for your help!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>ausrasul</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241740.html</guid>
		</item>
		<item>
			<title>Segmentation Faul</title>
			<link>http://www.daniweb.com/forums/thread241735.html</link>
			<pubDate>Fri, 27 Nov 2009 05:47:15 GMT</pubDate>
			<description><![CDATA[I have a seg fault I can't seem to be rid of.  Basically I'm building an AVL tree and I'm stuck on the insert method.  gdb says it is occuring on the line with: 
 
        while(  temp != NULL && temp->key != k ){ 
 
Would someone please help?  Thank you in advance. 
 
 
#include<vector>...]]></description>
			<content:encoded><![CDATA[<div>I have a seg fault I can't seem to be rid of.  Basically I'm building an AVL tree and I'm stuck on the insert method.  gdb says it is occuring on the line with:<br />
<br />
        while(  temp != NULL &amp;&amp; temp-&gt;key != k ){<br />
<br />
Would someone please help?  Thank you in advance.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;vector&gt;<br />
#include&lt;string&gt;<br />
#include&lt;cstring&gt;<br />
#include&lt;iostream&gt;<br />
#include&lt;fstream&gt;<br />
#include &lt;stdlib.h&gt; <br />
<br />
using namespace std;<br />
<br />
struct AVLNode{<br />
&nbsp; &nbsp; public:<br />
&nbsp; &nbsp; int balance;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int key;<br />
&nbsp; &nbsp; &nbsp; &nbsp; string data;<br />
&nbsp; &nbsp; &nbsp; &nbsp; AVLNode* leftchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; AVLNode* rightchild;<br />
<br />
<br />
};<br />
<br />
class AVLTree{<br />
<br />
&nbsp; &nbsp; public:<br />
&nbsp; &nbsp; AVLNode *root;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; /*<br />
&nbsp; &nbsp; &nbsp; &nbsp; *inserts a new node given the paramaters<br />
&nbsp; &nbsp; *in a the same fashion as a binary search tree<br />
&nbsp; &nbsp; *and then checks to see if AVL is violated<br />
&nbsp; &nbsp; * k is the key of the node which is an integer<br />
&nbsp; &nbsp; * d is the string for the info field<br />
&nbsp; &nbsp; * r is the root node of the AVL Tree<br />
&nbsp; &nbsp; */<br />
&nbsp; &nbsp; void AVLTreeInsert( int k, string d){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  AVLNode *temp = this-&gt;root; <br />
&nbsp; &nbsp; &nbsp; &nbsp; AVLNode *critNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; AVLNode *Rnode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool critNodeFound = false;&nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;what is up here&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; temp-&gt;key &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;i don't know&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(&nbsp; temp != NULL &amp;&amp; temp-&gt;key != k ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( temp-&gt;balance != 0 ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; critNode = temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; critNodeFound = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( k &lt; temp-&gt;key ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  temp = temp-&gt;leftchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = temp-&gt;rightchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(&nbsp; temp != NULL ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;data = d;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;data = d;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;key = k;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;leftchild = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;rightchild = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;balance = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( !critNodeFound ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode = this-&gt;root;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int d1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int d2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int d3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AVLNode *Cnode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AVLNode *Bnode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( k == critNode-&gt;key ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d1 = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cnode = critNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if( k &lt; critNode-&gt;key ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d1 = -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cnode = critNode-&gt;leftchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d1 = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cnode = critNode-&gt;rightchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( critNode-&gt;balance != d1 ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  critNode-&gt;balance = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Rnode = temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( k == Cnode-&gt;key ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d2 = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bnode = Cnode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if( k &lt; Cnode-&gt;key ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d2 = -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bnode = Cnode-&gt;leftchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d2 = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Bnode = Cnode-&gt;rightchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( d2 == d1 ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; critNode-&gt;balance = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode = Bnode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotate(critNode, -d1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( k == Bnode-&gt;key ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d3 = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode = Bnode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if( k &lt; Bnode-&gt;key ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d3 = -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode = Bnode-&gt;leftchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d3 = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode = Bnode-&gt;rightchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( d3 = d2){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; critNode-&gt;balance = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cnode-&gt;balance = d1;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if( d3 = -d2){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; critNode-&gt;balance = d2;&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; critNode-&gt;balance = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotate(Cnode, -d2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotate(critNode, -d1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while( Rnode-&gt;key != k ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( k == Rnode-&gt;key ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode-&gt;balance = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode = Rnode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if( k &lt; Rnode-&gt;key ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode-&gt;balance = -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode = Rnode-&gt;leftchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode-&gt;balance = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rnode = Rnode-&gt;rightchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }// end insert function<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; void rotate( AVLNode *rotateNode, int d ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  AVLNode *temp = rotateNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if( d == -1 ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotateNode = rotateNode-&gt;rightchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;rightchild = temp-&gt;rightchild-&gt;leftchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;rightchild-&gt;leftchild = temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rotateNode = rotateNode-&gt;leftchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;leftchild = temp-&gt;leftchild-&gt;rightchild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;leftchild-&gt;rightchild = temp;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }//end Rotate function<br />
<br />
};<br />
<br />
int main( int argc, char* argv&#91;&#93; ){<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; AVLTree tree;<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector&lt;string&gt; avlvector;<br />
&nbsp; &nbsp; &nbsp; &nbsp; string input;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream argfile( &quot;input.txt&quot; );<br />
&nbsp; &nbsp; &nbsp; &nbsp; if( argfile.is_open() ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while( !argfile.eof() ){<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getline( argfile, input );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; avlvector.push_back(input);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; argfile.close();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; string s;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; string helper;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char* number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int num;<br />
&nbsp; &nbsp; &nbsp; while( i &lt; avlvector.size() ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s = avlvector.at(i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  helper = s.substr(0,2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  number = new char&#91;helper.size() + 1 &#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  strcpy( number, helper.c_str() );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  num = atoi(number);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  tree.AVLTreeInsert( num, s.substr(3,5));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  i++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; while(1){}<br />
<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>DeadJustice</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241735.html</guid>
		</item>
		<item>
			<title>Compile Freezes (Says assignment is not working and to end task)</title>
			<link>http://www.daniweb.com/forums/thread241713.html</link>
			<pubDate>Fri, 27 Nov 2009 03:15:22 GMT</pubDate>
			<description><![CDATA[Hey can anyone tell me whats wrong with my code? I'm getting a program freeze. 
http://i47.tinypic.com/wh1ez5.png 
 
I'm doing  a binary search tree, 
BST.CPP 
http://pastebin.org/57667 
 
Person.CPP 
http://pastebin.org/57669]]></description>
			<content:encoded><![CDATA[<div>Hey can anyone tell me whats wrong with my code? I'm getting a program freeze.<br />
<a rel="nofollow" class="t" href="http://i47.tinypic.com/wh1ez5.png" target="_blank">http://i47.tinypic.com/wh1ez5.png</a><br />
<br />
I'm doing  a binary search tree,<br />
BST.CPP<br />
<a rel="nofollow" class="t" href="http://pastebin.org/57667" target="_blank">http://pastebin.org/57667</a><br />
<br />
Person.CPP<br />
<a rel="nofollow" class="t" href="http://pastebin.org/57669" target="_blank">http://pastebin.org/57669</a><br />
<br />
TreeNode.CPP<br />
<a rel="nofollow" class="t" href="http://pastebin.org/57670" target="_blank">http://pastebin.org/57670</a><br />
<br />
Main---Where I call the searchTreeInsert function<br />
<a rel="nofollow" class="t" href="http://pastebin.org/57674" target="_blank">http://pastebin.org/57674</a></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Kennych</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241713.html</guid>
		</item>
		<item>
			<title>Game Help.</title>
			<link>http://www.daniweb.com/forums/thread241712.html</link>
			<pubDate>Fri, 27 Nov 2009 02:42:37 GMT</pubDate>
			<description><![CDATA[I am trying to make a code, where the points are not working. The points always give an odd number. Can you try it, if you can see a problem, I would love help. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>I am trying to make a code, where the points are not working. The points always give an odd number. Can you try it, if you can see a problem, I would love help.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#define cls system(&quot;cls&quot;)<br />
#define pause system(&quot;pause&quot;)<br />
#include &lt;string&gt;<br />
<br />
using namespace std;<br />
<br />
class games<br />
{<br />
&nbsp; public:<br />
&nbsp;  long double points;<br />
&nbsp;  int tictactoe(void);&nbsp; &nbsp; <br />
};<br />
<br />
int games::tictactoe(void)<br />
{<br />
&nbsp;int computer, playerint;<br />
&nbsp;string player;<br />
&nbsp;computer = rand()%(2);<br />
&nbsp;cls;<br />
&nbsp;cout &lt;&lt; &quot;Heads (h) or Tails (t)?&quot;;<br />
&nbsp;cin &gt;&gt; player;&nbsp; <br />
&nbsp;if (player == &quot;t&quot; || player == &quot;T&quot;)<br />
&nbsp;{<br />
&nbsp; playerint = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp;} else if(player == &quot;h&quot; || player == &quot;H&quot;)<br />
&nbsp;{<br />
&nbsp; playerint = 1;&nbsp; &nbsp; &nbsp;  <br />
&nbsp;}<br />
&nbsp;if (playerint == computer)<br />
&nbsp;{<br />
&nbsp; cls;<br />
&nbsp; cout &lt;&lt; &quot;Well done! You Won!&nbsp;  +100 Points!&quot; &lt;&lt; endl;<br />
&nbsp; pause;<br />
&nbsp; points += 100;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp;} else <br />
&nbsp;{<br />
&nbsp; cls;<br />
&nbsp; cout &lt;&lt; &quot;Sorry! You Lost!&nbsp;  -100 Points!&quot; &lt;&lt; endl;<br />
&nbsp; pause;<br />
&nbsp; points -= 100;&nbsp; &nbsp; &nbsp;  <br />
&nbsp;}<br />
}<br />
<br />
<br />
int chooser()<br />
{<br />
&nbsp;int selection = 0;<br />
&nbsp;int temp;<br />
&nbsp;games player1;<br />
&nbsp;cls;<br />
&nbsp;cout &lt;&lt; &quot;Your Choices:&quot; &lt;&lt; endl &lt;&lt; &quot;1. Tic Tac Toe&quot; &lt;&lt; endl &lt;&lt; &quot;5. View Profile&quot; &lt;&lt; endl &lt;&lt; &quot;0. Exit&quot; &lt;&lt; endl &lt;&lt; &quot;Your Choice:&quot;;<br />
&nbsp;cin &gt;&gt; selection;<br />
&nbsp;if (selection == 1)<br />
&nbsp;{<br />
&nbsp; player1.tictactoe();&nbsp; <br />
&nbsp;} else if (selection == 5){<br />
&nbsp; cls;<br />
&nbsp; cout &lt;&lt; &quot;Points: &quot; &lt;&lt; player1.points &lt;&lt; endl;<br />
&nbsp; pause;<br />
&nbsp; cls;<br />
&nbsp; chooser();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp;} else if(selection == 0) <br />
&nbsp;{<br />
&nbsp; return 0;&nbsp; &nbsp; &nbsp; <br />
&nbsp;} else {<br />
&nbsp;cls;<br />
&nbsp;chooser();&nbsp; &nbsp; &nbsp;  <br />
}<br />
chooser();<br />
}<br />
<br />
int main()<br />
{<br />
&nbsp;chooser(); <br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>redback93</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241712.html</guid>
		</item>
		<item>
			<title>backgroundworker calling an event problem</title>
			<link>http://www.daniweb.com/forums/thread241693.html</link>
			<pubDate>Fri, 27 Nov 2009 00:52:08 GMT</pubDate>
			<description>I think I am missing out some logic when it comes to the backgroundworker. 
 
For this scenario. I am using a loop in the backgroundworker. 
Each loop I am calling an event that is writing values to a file. 
After writing these values, I am increasing updateValue. 
 
The problem is that the...</description>
			<content:encoded><![CDATA[<div>I think I am missing out some logic when it comes to the backgroundworker.<br />
<br />
For this scenario. I am using a loop in the backgroundworker.<br />
Each loop I am calling an event that is writing values to a file.<br />
After writing these values, I am increasing updateValue.<br />
<br />
The problem is that the backgroundworker doesn´t get this updated updateValue for next looping.<br />
<br />
However I have done a test with Sleep(5000) to see if the Messagebox will show the increased value. In this case it does.<br />
<br />
I wonder why this is happening and what is the correct way to solve this problem.<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; private: Void backgroundWorker1_DoWork(Object^ sender, DoWorkEventArgs^ e)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( int i = 0; i &lt; 5; i++ )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Thread.Sleep(5000); If using sleep the Messagebox will show correct updateValue, otherwise not.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.Show(updateValue.ToString());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RF.t1 += gcnew t1DataEventHandler(this.t1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int updateValue = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private: Void t1(Object^ sender, t1DataEvent^ e)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Write to file. (Takes about 1 second each time)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; updateValue = updateValue + 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Darth Vader</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241693.html</guid>
		</item>
		<item>
			<title>Pacman collision detection</title>
			<link>http://www.daniweb.com/forums/thread241689.html</link>
			<pubDate>Fri, 27 Nov 2009 00:21:32 GMT</pubDate>
			<description><![CDATA[Ok.  
I've been working on a pacman game using C++, and OGRE. Things have been going good, but I have run across a problem with the collision detection of pacman hitting the walls.  
Before I explaing, here is some of the source code.  
 
PacpersonObj Class Header 
  <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>Ok. <br />
I've been working on a pacman game using C++, and OGRE. Things have been going good, but I have run across a problem with the collision detection of pacman hitting the walls. <br />
Before I explaing, here is some of the source code. <br />
<br />
PacpersonObj Class Header<br />
 <pre style="margin:20px; line-height:13px">// PacPersonObj.h<br />
&nbsp;// PacPersonObj class definition (represents a PacPersonObj in the game).<br />
&nbsp;#ifndef PacPersonObj_H<br />
&nbsp;#define PacPersonObj_H<br />
<br />
&nbsp;#include &lt;Ogre.h&gt; // Ogre class definition<br />
&nbsp;using namespace Ogre; // use the Ogre namespace<br />
<br />
<br />
&nbsp;const int RADIUS = 5; // the radius of the Pacperson<br />
<br />
<br />
<br />
&nbsp;class PacPersonObj<br />
&nbsp;{<br />
&nbsp;public:<br />
&nbsp; &nbsp; // constructor<br />
&nbsp; &nbsp; PacPersonObj( SceneManager *sceneManagerPtr );<br />
&nbsp; &nbsp; ~PacPersonObj(); // destructor<br />
&nbsp; &nbsp; &nbsp; &nbsp; void movePac( const Vector3 &amp;direction ); // move a PacPersonObj<br />
&nbsp; &nbsp; void addToScene(); // add a PacPersonObj to the scene<br />
&nbsp; &nbsp; &nbsp; &nbsp; void movePac2( Real time ); // move the pacperson across the screen<br />
&nbsp; &nbsp; &nbsp; &nbsp; void setDirection(Vector3);<br />
<br />
<br />
&nbsp; &nbsp; <br />
<br />
&nbsp;private:<br />
&nbsp; &nbsp; SceneManager* sceneManagerPtr; // pointer to the SceneManager<br />
&nbsp; &nbsp; SceneNode *nodePtr; // pointer to a SceneNode&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; String name; // name of the PacPersonObj<br />
&nbsp; &nbsp; //int x;// x-coordinate of the PacPersonObj<br />
//&nbsp; &nbsp; &nbsp; &nbsp; int y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; void reverseHorizontalDirection() ; // change horizontal direction<br />
&nbsp; &nbsp; void reverseVerticalDirection(); // change vertical direction<br />
&nbsp; &nbsp; &nbsp; &nbsp; int speed; // speed of the Pacperson<br />
&nbsp; &nbsp; Vector3 direction; // direction of the Pacperson<br />
<br />
<br />
<br />
&nbsp;}; // end of class PacPersonObj<br />
<br />
&nbsp;#endif // PacPersonObj_H</pre><br />
PacpersonObj Class .cpp<br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
<br />
void PacPersonObj::setDirection(Vector3 newNirection)<br />
&nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  direction = newNirection;<br />
&nbsp;}<br />
<br />
&nbsp;void PacPersonObj::movePac2( Real time)<br />
{<br />
&nbsp;  nodePtr-&gt;translate( ( direction * ( speed * time ) ) ); // move pac <br />
&nbsp;  Vector3 position = nodePtr-&gt;getPosition(); // get pac's new position<br />
<br />
&nbsp; &nbsp;  // get the positions of the four walls<br />
&nbsp; &nbsp; Vector3 topPosition = sceneManagerPtr-&gt;&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  getSceneNode( &quot;WallTop&quot; )-&gt;getPosition();<br />
&nbsp; &nbsp; Vector3 bottomPosition = sceneManagerPtr-&gt;<br />
&nbsp; &nbsp; &nbsp;  getSceneNode( &quot;WallBottom&quot; )-&gt;getPosition();<br />
&nbsp; &nbsp; Vector3 leftPosition = sceneManagerPtr-&gt;<br />
&nbsp; &nbsp; &nbsp;  getSceneNode( &quot;WallLeft&quot; )-&gt;getPosition();<br />
&nbsp; &nbsp; Vector3 rightPosition = sceneManagerPtr-&gt;<br />
&nbsp; &nbsp; &nbsp;  getSceneNode( &quot;WallRight&quot; )-&gt;getPosition();<br />
<br />
&nbsp; &nbsp; const int WALL_WIDTH = 20; // the width of the walls<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; // check if the Pac hit the left side<br />
&nbsp; &nbsp; if ( ( position.x - RADIUS ) &lt;= leftPosition.x + ( WALL_WIDTH / 2 ) )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  nodePtr-&gt;setPosition(0,0,0); // move pac <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  Pacperson::waitTrueToggle();<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; } // end if<br />
&nbsp; &nbsp; // check if the Pac hit the right side<br />
&nbsp; &nbsp; if (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  ( position.x + RADIUS ) &gt;= rightPosition.x - ( WALL_WIDTH / 2 ) )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  nodePtr-&gt;setPosition( (rightPosition.x - ( WALL_WIDTH / 2 ) - RADIUS ),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  position.y , position.z );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  Pacperson::updateScore( Players::PLAYER1 ); // update the score<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; } // end else<br />
&nbsp; &nbsp; // check if the Pac hit the bottom wall<br />
&nbsp; &nbsp; else if (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  ( position.y - RADIUS ) &lt;= bottomPosition.y + ( WALL_WIDTH / 2 ) &amp;&amp;<br />
&nbsp; &nbsp; &nbsp;  direction.y &lt; 0 )&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  // place the Pac on the bottom wall<br />
&nbsp; &nbsp; &nbsp;  nodePtr-&gt;setPosition( position.x,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( bottomPosition.y + ( WALL_WIDTH / 2 ) + RADIUS ), position.z );<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; } // end else<br />
&nbsp; &nbsp; // check if the Pac hit the top wall<br />
&nbsp; &nbsp; else if (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; ( position.y + RADIUS ) &gt;= topPosition.y - ( WALL_WIDTH / 2 ) &amp;&amp;<br />
&nbsp; &nbsp; &nbsp; direction.y &gt; 0 )&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; // place the Pac on the top wall<br />
&nbsp; &nbsp; &nbsp; nodePtr-&gt;setPosition( position.x,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  ( topPosition.y - ( WALL_WIDTH / 2 ) - RADIUS ), position.z );<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp;  } // end else<br />
<br />
&nbsp;<br />
&nbsp;} // end function movePac<br />
<br />
<br />
void PacPersonObj::reverseHorizontalDirection()<br />
&nbsp;{<br />
&nbsp; &nbsp; direction *= Vector3( -1, 1, 1 ); // reverse the horizontal direction<br />
&nbsp;} // end function reverseHorizontalDirection<br />
<br />
&nbsp;// reverse the Pacperson's vertical direction<br />
&nbsp;void PacPersonObj::reverseVerticalDirection()<br />
&nbsp;{<br />
&nbsp; &nbsp; direction *= Vector3( 1, -1, 1 ); // reverse the vertical direction<br />
&nbsp;} // end function reverseVerticalDirection</pre><br />
Class that implements ( relevent functions)<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;sstream&gt;<br />
&nbsp; using std::ostringstream;<br />
<br />
&nbsp; #include &lt;stdexcept&gt;<br />
&nbsp; using std::runtime_error;<br />
<br />
&nbsp; #include &lt;Ogre.h&gt; // Ogre class definition<br />
&nbsp; using namespace Ogre; // use the Ogre namespace<br />
<br />
&nbsp; #include &lt;OgreStringConverter.h&gt; // OgreStringConverter class definition<br />
&nbsp; #include &lt;OIS\OISEvents.h&gt; // OISEvents class definition<br />
&nbsp; #include &lt;OIS\OISInputManager.h&gt; // OISInputManager class definition<br />
&nbsp; #include &lt;OIS\OISKeyboard.h&gt; // OISKeyboard class definition<br />
&nbsp; #include &quot;powerUp.h&quot;<br />
&nbsp; #include &quot;PacPersonObj.h&quot;<br />
&nbsp; #include &quot;newTut.h&quot;<br />
<br />
&nbsp; int Pacperson::player1Score = 0; // initialize player 1's score to 0<br />
&nbsp; int Pacperson::player2Score = 0; // initialize player 2's score to 0<br />
&nbsp; bool Pacperson::wait = false; // initialize wait to false<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // directions to move the Paddles<br />
&nbsp; const Vector3 PACPERSON_DOWN = Vector3( 0, -1, 0 );<br />
&nbsp; const Vector3 PACPERSON_UP = Vector3( 0, 1, 0 );&nbsp;  <br />
&nbsp; const Vector3 PACPERSON_LEFT = Vector3( -1, 0, 0 );<br />
&nbsp; const Vector3 PACPERSON_RIGHT = Vector3( 1, 0, 0 );&nbsp; <br />
<br />
<br />
<br />
&nbsp; <br />
//////////////ommitted objects///////////////<br />
<br />
<br />
<br />
PacPersonObjPtr = new PacPersonObj( sceneManagerPtr ); // make the PacPerson<br />
&nbsp; &nbsp; PacPersonObjPtr-&gt;addToScene(); // add the PacPersonObj to the scene<br />
<br />
<br />
// update the score<br />
&nbsp;void Pacperson::updateScore( Players player )<br />
&nbsp;{<br />
&nbsp; &nbsp; // increase the correct player's score<br />
&nbsp; &nbsp; if ( player == Players::PLAYER1 )<br />
&nbsp; &nbsp; &nbsp;  player1Score++;<br />
&nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp;  player2Score++;<br />
<br />
&nbsp; &nbsp; wait = true; // the game should wait to restart the Pacperson<br />
&nbsp; &nbsp; updateScoreText(); // update the score text on the screen<br />
&nbsp;} // end function updateScore<br />
<br />
&nbsp;// update the score text<br />
&nbsp;void Pacperson::updateScoreText()<br />
&nbsp;{<br />
&nbsp; &nbsp; ostringstream scoreText; // text to be displayed<br />
<br />
&nbsp; &nbsp; scoreText &lt;&lt; &quot;Player 2 Score: &quot; &lt;&lt; player2Score; // make the text<br />
<br />
&nbsp; &nbsp; // get the right player's TextArea<br />
&nbsp; &nbsp; OverlayElement *textElementPtr =<br />
&nbsp; &nbsp; &nbsp;  OverlayManager::getSingletonPtr()-&gt;getOverlayElement( &quot;right&quot; );<br />
&nbsp; &nbsp; textElementPtr-&gt;setCaption( scoreText.str() ); // set the text<br />
<br />
&nbsp; &nbsp; scoreText.str( &quot;&quot; ); // reset the text in scoreText<br />
&nbsp; &nbsp; scoreText &lt;&lt; &quot;Player 1 Score: &quot; &lt;&lt; player1Score; // make the text<br />
<br />
&nbsp; &nbsp; // get the left player's TextArea<br />
&nbsp; &nbsp; textElementPtr =<br />
&nbsp; &nbsp; &nbsp;  OverlayManager::getSingletonPtr()-&gt;getOverlayElement( &quot;left&quot; );<br />
&nbsp; &nbsp; textElementPtr-&gt;setCaption( scoreText.str() ); // set the text<br />
&nbsp;} // end function updateScoreText<br />
<br />
&nbsp;// respond to user keyboard input<br />
&nbsp;bool Pacperson::keyPressed( const OIS::KeyEvent &amp;keyEventRef )<br />
&nbsp;{<br />
&nbsp; &nbsp; // if the game is not paused<br />
&nbsp; &nbsp; if ( !pause )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  // process KeyEvents that apply when the game is not paused<br />
&nbsp; &nbsp; &nbsp;  switch ( keyEventRef.key )<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  case OIS::KC_ESCAPE: // escape key hit: quit<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; quit = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; case OIS::KC_UP: // up-arrow key hit: move the right Pacpersonup<br />
&nbsp; &nbsp; &nbsp; &nbsp;  PacPersonObjPtr-&gt;setDirection(PACPERSON_UP);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  wait = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp;  case OIS::KC_DOWN: // down-arrow key hit: move the right Pacpersondown<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PacPersonObjPtr-&gt;setDirection( PACPERSON_DOWN );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wait = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  case OIS::KC_LEFT: // up-arrow key hit: move the right Pacpersonup<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PacPersonObjPtr-&gt;setDirection( PACPERSON_LEFT );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wait = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp;  case OIS::KC_RIGHT: // down-arrow key hit: move the right Pacpersondown<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PacPersonObjPtr-&gt;setDirection( PACPERSON_RIGHT );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wait = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; case OIS::KC_P: // P key hit: pause the game<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pause = true; // set pause to true when the user pauses the game<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Overlay *pauseOverlayPtr =&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  OverlayManager::getSingleton().getByName( &quot;PauseOverlay&quot; );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pauseOverlayPtr-&gt;show(); // show the pause Overlay&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp;  } // end switch<br />
&nbsp; &nbsp; } // end if<br />
&nbsp; &nbsp; else // game is paused<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  // user hit 'R' on the keyboard<br />
&nbsp; &nbsp; &nbsp;  if ( keyEventRef.key == OIS::KC_R )<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pause = false; // set pause to false when user resumes the game<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Overlay *pauseOverlayPtr =&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  OverlayManager::getSingleton().getByName( &quot;PauseOverlay&quot; );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pauseOverlayPtr-&gt;hide(); // hide the pause Overlay&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;  } // end if<br />
&nbsp; &nbsp; } // end else<br />
&nbsp; &nbsp; return true;<br />
&nbsp;} // end function keyPressed<br />
<br />
&nbsp;// process key released events<br />
&nbsp;bool Pacperson::keyReleased( const OIS::KeyEvent &amp;keyEventRef )<br />
&nbsp;{<br />
&nbsp; &nbsp; return true;<br />
&nbsp;} // end function keyReleased<br />
<br />
&nbsp;// return true if the program should render the next frame<br />
&nbsp;bool Pacperson::frameEnded( const FrameEvent &amp;frameEvent )<br />
&nbsp;{<br />
&nbsp; &nbsp; return !quit; // quit = false if the user hasn't quit yet<br />
&nbsp;} // end function frameEnded<br />
<br />
&nbsp;bool Pacperson::frameStarted( const FrameEvent &amp;frameEvent )<br />
&nbsp;{<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  keyboardPtr-&gt;capture(); // get keyboard events<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if ( !wait &amp;&amp; !pause )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  // move the Pacperson<br />
&nbsp; &nbsp; &nbsp;  PacPersonObjPtr-&gt;movePac2( frameEvent.timeSinceLastFrame);<br />
&nbsp; &nbsp; } // end if<br />
&nbsp; &nbsp; // don't move the Pacperson if wait is true<br />
&nbsp; &nbsp; else if ( wait )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  // increase time if it is less than 4 seconds<br />
&nbsp; &nbsp; &nbsp;  if ( time &lt; 4 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // add the seconds since the last frame<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time += frameEvent.timeSinceLastFrame;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wait = false; // shouldn't wait to move the Pacperson any more<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time = 0; // reset the control variable to 0<br />
&nbsp; &nbsp; &nbsp;  } // end else<br />
&nbsp; &nbsp; } // end else<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  return !quit; // quit = false if the user hasn't quit yet<br />
&nbsp;} // end function frameStarted<br />
<br />
// sets wait to true<br />
&nbsp;void Pacperson::waitTrueToggle()<br />
&nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  wait = true;<br />
&nbsp;}</pre><br />
<br />
OK now for the explanation. <br />
In the PacpersonObj Class .cpp source, I define the function.<br />
<br />
 <pre style="margin:20px; line-height:13px">void PacPersonObj::movePac2( Real time)</pre><br />
 <br />
<br />
 This function recieves a time parameter from the class that implements its. <br />
It uses that time to to move the object using .<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp;  nodePtr-&gt;translate( ( direction * ( speed * time ) ) ); <br />
&nbsp;  Vector3 position = nodePtr-&gt;getPosition();</pre><br />
I sets the location of the walls and uses if/ else statements to check for collisions with the walls . <br />
<br />
The directions is set by the <br />
 <pre style="margin:20px; line-height:13px">void PacPersonObj::setDirection(Vector3 newNirection)</pre><br />
This direction is sent to it by the from the class that implements its. <br />
<br />
Specifically the keyPressed function , and the frameStarted functions.<br />
<br />
???????????????????<br />
My Problem!<br />
???????????????????<br />
<br />
When ever I run the game.  the ball dissapears. I have tried many diffrent things to fix this, and have discovered something that I don't understand. <br />
<br />
<br />
When the code is like this :<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; if ( ( position.x - RADIUS ) &lt;= leftPosition.x + ( WALL_WIDTH / 2 ) )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  nodePtr-&gt;setPosition(0,0,0); // move pac <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  Pacperson::waitTrueToggle();<br />
&nbsp; &nbsp;  <br />
}</pre><br />
The ball appears, and the collision detection works, except for this first part of the if/else statements. I can set the &quot; nodePtr-&gt;setPosition(0,0,0); &quot; to anywhere , and it will go back to that point after it hits the wall, but it also starts there when the game starts. <br />
<br />
I just want it to stop at the wall like my other if else's do , but if I change the code like the other if/else statements, the ball dissapears as soon as it starts. <br />
<br />
My though is that is is reading my fist if statement too early.<br />
<br />
any ideas??<br />
<br />
Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>luskbo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241689.html</guid>
		</item>
		<item>
			<title>Making a Game, Having Code Trouble -- ERRORS!! PLEASE HELP!!</title>
			<link>http://www.daniweb.com/forums/thread241684.html</link>
			<pubDate>Fri, 27 Nov 2009 00:03:21 GMT</pubDate>
			<description><![CDATA[Hello! I am making a text-based game (I am new to C++) called The Final Journey (I made the name up, didn't copy) and I have had some trouble with the code. I am using Dev-C++ (I plan to get VC++), just so you know. Here is what I have so far: 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hello! I am making a text-based game (I am new to C++) called The Final Journey (I made the name up, didn't copy) and I have had some trouble with the code. I am using Dev-C++ (I plan to get VC++), just so you know. Here is what I have so far:<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream.h&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Intro<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Welcome to The Final Journey v. 0.0.3 Alpha.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;You are an adventurer, traveling from town to town, looking for monsters and bold followers.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Your homeland is Chosan, a small town on the Cho River. Through the years, you have traveled far and wide, eventually returning in your home land.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; &quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; &quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;This... is where you begin...&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;THE FINAL JOURNEY.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Variables<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Attributes<br />
&nbsp; &nbsp; &nbsp; &nbsp; double HP = 25;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double str = 10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double def = 10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double energy = 100;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double Army = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Other Variables<br />
&nbsp; &nbsp; int rannum = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int selectnum = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double tpts = 0.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int train_a = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char tc1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char tc3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char tc2;<br />
&nbsp; &nbsp; char tin;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double strlvlup = 0.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double HPlvlup = 0.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double deflvlup = 0.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; /*Random Integer 1-9 Generator<br />
&nbsp; &nbsp; &nbsp; &nbsp; srand ( time(NULL) );<br />
&nbsp; &nbsp; &nbsp; &nbsp; rannum = rand() % 9 + 1;*/ //Between comments ( /*Here!*/ ) in random number generator.<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Game Starts<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //WAKE UP<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;*You wake up to a normal day in Chosan, and your energy is fully recharged.*&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Here are your attributes:&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Health (HP): \t&quot;&lt;&lt;HP&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Strength (Str): \t&quot;&lt;&lt;str&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Defence (Def): \t&quot;&lt;&lt;def&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Energy (En): \t&quot;&lt;&lt;energy&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Army Size (Army): \t&quot;&lt;&lt;Army&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Let's get dressed and do some daily training, then embark on our journey.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;*You get dressed and grab your sword and shield.*&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //TRAINING ARENA<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;*You enter the training arena. A man is there waiting for you.*&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Man: Hello. I am your trainer for today.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;You: Okay, let's begin.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Man: Here are the instructions: I Will tell you a letter from your qwerty keyboard. The possible letters are, Q W E A S D Z X C, the left-most 3x3 of letters.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Man: You are to input the letter given to score a point, otherwise, you lose half a point.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Man: The points go to your Str and Def skills.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Man: READY???&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //TRAINING SEQUENCE<br />
&nbsp; &nbsp; &nbsp; &nbsp; do {<br />
&nbsp; &nbsp; &nbsp; &nbsp; srand ( time(NULL) );<br />
&nbsp; &nbsp; &nbsp; &nbsp; rannum = rand() % 9 + 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; train_a = train_a + 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (rannum == 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  tc2 = &quot;Q&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt;tc1&lt;&lt;tc2&lt;&lt;tc3&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cin &gt;&gt; tin&gt;&gt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (tin == &quot;Q&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts + 1;<br />
&nbsp; &nbsp; &nbsp;  else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts - 0.5;<br />
&nbsp; &nbsp; else if (rannum == 2);<br />
&nbsp; &nbsp; &nbsp;  tc2 = &quot;W&quot;;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt;tc1&lt;&lt;tc2&lt;&lt;tc3&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; tin&gt;&gt;endl;<br />
&nbsp; &nbsp; &nbsp;  if (tin == &quot;W&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts + 1;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts - 0.5;<br />
&nbsp; &nbsp; else if (rannum == 3);<br />
&nbsp; &nbsp; &nbsp;  tc2 = &quot;E&quot;;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; tc1&lt;&lt;tc2&lt;&lt;tc3&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; tin&gt;&gt;endl;<br />
&nbsp; &nbsp; &nbsp;  if (tin == &quot;E&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts + 1;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts - 0.5;<br />
&nbsp; &nbsp; else if (rannum == 4);<br />
&nbsp; &nbsp; &nbsp;  tc2 = &quot;A&quot;;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; tc1&lt;&lt;tc2&lt;&lt;tc3&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; tin&gt;&gt;endl;<br />
&nbsp; &nbsp; &nbsp;  if (tin == &quot;A&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts + 1;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts - 0.5;<br />
&nbsp; &nbsp; else if (rannum == 5);<br />
&nbsp; &nbsp; &nbsp;  tc2 = &quot;S&quot;;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; tc1&lt;&lt;tc2&lt;&lt;tc3&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; tin&gt;&gt;endl;<br />
&nbsp; &nbsp; &nbsp;  if (tin == &quot;S&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts + 1;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts - 0.5;<br />
&nbsp; &nbsp; else if (rannum == 6);<br />
&nbsp; &nbsp; &nbsp;  tc2 = &quot;D&quot;;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; tc1&lt;&lt;tc2&lt;&lt;tc3&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; tin&gt;&gt;endl;<br />
&nbsp; &nbsp; &nbsp;  if (tin == &quot;D&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts + 1;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts - 0.5;<br />
&nbsp; &nbsp; else if (rannum == 7);<br />
&nbsp; &nbsp; &nbsp;  tc2 = &quot;Z&quot;;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; tc1&lt;&lt;tc2&lt;&lt;tc3&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; tin&gt;&gt;endl;<br />
&nbsp; &nbsp; &nbsp;  if (tin == &quot;Z&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts + 1;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts - 0.5;<br />
&nbsp; &nbsp; else if (rannum == 8);<br />
&nbsp; &nbsp; &nbsp;  tc2 = &quot;X&quot;;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; tc1&lt;&lt;tc2&lt;&lt;tc3&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; tin&gt;&gt;endl;<br />
&nbsp; &nbsp; &nbsp;  if (tin == &quot;X&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts + 1;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts - 0.5;<br />
&nbsp; &nbsp; else if (rannum == 9);<br />
&nbsp; &nbsp; &nbsp;  tc2 = &quot;C&quot;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; tc1&lt;&lt;tc2&lt;&lt;tc3&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; tin&gt;&gt;endl;<br />
&nbsp; &nbsp; &nbsp;  if (tin == &quot;C&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts + 1;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tpts = tpts - 0.5;<br />
&nbsp; &nbsp; }while (train_a &lt; 10);<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Man: Good job, you earned &quot;&lt;&lt;tpts&lt;&lt;&quot; points which will help your Strength and Defence levels.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; strlvlup = (tpts / 2) / 2;<br />
&nbsp; &nbsp; str = str + strlvlup;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;STRENGTH LEVEL UP. YOU NOW HAVE &quot;&lt;&lt;str&lt;&lt;&quot; STRENGTH POINTS.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; deflvlup = (tpts / 2) / 2;<br />
&nbsp; &nbsp; def = def + deflvlup;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;DEFENCE LEVEL UP. YOU NOW HAVE &quot;&lt;&lt;def&lt;&lt;&quot; DEFENCE POINTS.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Man: Good job, adventurer.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;WOULD YOU LIKE THIS MAN TO JOIN YOUR ARMY? 1. YES, 2. NO&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; cin &gt;&gt; selectnum&gt;&gt;endl;<br />
&nbsp; &nbsp; if (selectnum == 1)<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;You: Would you like to join my army? You would be the first.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Man: Yes, I am Sir Gillington.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;You: Okay, Sir Gillington, lets travel.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  Army = Army + 1;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;ARMY BONUS. YOU NOW HAVE &quot;&lt;&lt;Army&lt;&lt;&quot; PEOPLE IN YOUR ARMY.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; if (selectnum == 2)<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Your army stays the same size (1).&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Lets travel!&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp;  return 0;<br />
}</pre>I get these errors:<br />
--------------------------------------------------------------------<br />
LINE --- MESSAGE<br />
--------------------------------------------------------------------<br />
86         invalid conversion from `const char*' to `char'<br />
87         no match for 'operator&gt;&gt;' in 'std::operator&gt;&gt; [with _CharT = char, _Traits = std::char_traits&lt;char&gt;](((std::basic_istream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)(&amp;std::cin)), ((char&amp;)(&amp;tin))) &gt;&gt; std::endl' <br />
--------------------------------------------------------------------<br />
<br />
Can someone please help? (And also, if the city name &quot;Chosan&quot; and &quot;Cho River&quot; are real, tell me. I came up with them by randomly pressing a few letters like this: fnoq = funoq or funoque or something like that)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bman214</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241684.html</guid>
		</item>
		<item>
			<title>Pacman collision detection</title>
			<link>http://www.daniweb.com/forums/thread241683.html</link>
			<pubDate>Thu, 26 Nov 2009 23:49:36 GMT</pubDate>
			<description><![CDATA[Ok.  
I've been working on a pacman game using C++, and OGRE. Things have been going good, but I have run across a problem with the collision detection of pacman hitting the walls.  
Before I explaing, here is some of the source code.  
 
PacpersonObj Class Header 
  <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>Ok. <br />
I've been working on a pacman game using C++, and OGRE. Things have been going good, but I have run across a problem with the collision detection of pacman hitting the walls. <br />
Before I explaing, here is some of the source code. <br />
<br />
PacpersonObj Class Header<br />
 <pre style="margin:20px; line-height:13px">// PacPersonObj.h<br />
&nbsp;// PacPersonObj class definition (represents a PacPersonObj in the game).<br />
&nbsp;#ifndef PacPersonObj_H<br />
&nbsp;#define PacPersonObj_H<br />
<br />
&nbsp;#include &lt;Ogre.h&gt; // Ogre class definition<br />
&nbsp;using namespace Ogre; // use the Ogre namespace<br />
<br />
<br />
&nbsp;const int RADIUS = 5; // the radius of the Ball<br />
<br />
<br />
<br />
&nbsp;class PacPersonObj<br />
&nbsp;{<br />
&nbsp;public:<br />
&nbsp; &nbsp; // constructor<br />
&nbsp; &nbsp; PacPersonObj( SceneManager *sceneManagerPtr );<br />
&nbsp; &nbsp; ~PacPersonObj(); // destructor<br />
&nbsp; &nbsp; &nbsp; &nbsp; void movePac( const Vector3 &amp;direction ); // move a PacPersonObj<br />
&nbsp; &nbsp; void addToScene(); // add a PacPersonObj to the scene<br />
&nbsp; &nbsp; &nbsp; &nbsp; void movePac2( Real time ); // move the pacperson across the screen<br />
&nbsp; &nbsp; &nbsp; &nbsp; void setDirection(Vector3);<br />
<br />
<br />
&nbsp; &nbsp; <br />
<br />
&nbsp;private:<br />
&nbsp; &nbsp; SceneManager* sceneManagerPtr; // pointer to the SceneManager<br />
&nbsp; &nbsp; SceneNode *nodePtr; // pointer to a SceneNode&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; String name; // name of the PacPersonObj<br />
&nbsp; &nbsp; //int x;// x-coordinate of the PacPersonObj<br />
//&nbsp; &nbsp; &nbsp; &nbsp; int y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; void reverseHorizontalDirection() ; // change horizontal direction<br />
&nbsp; &nbsp; void reverseVerticalDirection(); // change vertical direction<br />
&nbsp; &nbsp; &nbsp; &nbsp; int speed; // speed of the Ball<br />
&nbsp; &nbsp; Vector3 direction; // direction of the Ball<br />
<br />
<br />
<br />
&nbsp;}; // end of class PacPersonObj<br />
<br />
&nbsp;#endif // PacPersonObj_H</pre><br />
PacpersonObj Class .cpp<br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
&nbsp;void PacPersonObj::movePac2( Real time)<br />
{<br />
&nbsp;  nodePtr-&gt;translate( ( direction * ( speed * time ) ) ); // move pac <br />
&nbsp;  Vector3 position = nodePtr-&gt;getPosition(); // get pac's new position<br />
<br />
&nbsp; &nbsp;  // get the positions of the four walls<br />
&nbsp; &nbsp; Vector3 topPosition = sceneManagerPtr-&gt;&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  getSceneNode( &quot;WallTop&quot; )-&gt;getPosition();<br />
&nbsp; &nbsp; Vector3 bottomPosition = sceneManagerPtr-&gt;<br />
&nbsp; &nbsp; &nbsp;  getSceneNode( &quot;WallBottom&quot; )-&gt;getPosition();<br />
&nbsp; &nbsp; Vector3 leftPosition = sceneManagerPtr-&gt;<br />
&nbsp; &nbsp; &nbsp;  getSceneNode( &quot;WallLeft&quot; )-&gt;getPosition();<br />
&nbsp; &nbsp; Vector3 rightPosition = sceneManagerPtr-&gt;<br />
&nbsp; &nbsp; &nbsp;  getSceneNode( &quot;WallRight&quot; )-&gt;getPosition();<br />
<br />
&nbsp; &nbsp; const int WALL_WIDTH = 20; // the width of the walls<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; // check if the Pac hit the left side<br />
&nbsp; &nbsp; if ( ( position.x - RADIUS ) &lt;= leftPosition.x + ( WALL_WIDTH / 2 ) )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  nodePtr-&gt;setPosition(0,0,0); // move pac <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  Pacperson::updateScore( Players::PLAYER2 ); // update the score<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; } // end if<br />
&nbsp; &nbsp; // check if the Pac hit the right side<br />
&nbsp; &nbsp; if (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  ( position.x + RADIUS ) &gt;= rightPosition.x - ( WALL_WIDTH / 2 ) )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  nodePtr-&gt;setPosition( (rightPosition.x - ( WALL_WIDTH / 2 ) - RADIUS ),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  position.y , position.z );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  Pacperson::updateScore( Players::PLAYER1 ); // update the score<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; } // end else<br />
&nbsp; &nbsp; // check if the Pac hit the bottom wall<br />
&nbsp; &nbsp; else if (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  ( position.y - RADIUS ) &lt;= bottomPosition.y + ( WALL_WIDTH / 2 ) &amp;&amp;<br />
&nbsp; &nbsp; &nbsp;  direction.y &lt; 0 )&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  // place the Pac on the bottom wall<br />
&nbsp; &nbsp; &nbsp;  nodePtr-&gt;setPosition( position.x,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( bottomPosition.y + ( WALL_WIDTH / 2 ) + RADIUS ), position.z );<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; } // end else<br />
&nbsp; &nbsp; // check if the Pac hit the top wall<br />
&nbsp; &nbsp; else if (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; ( position.y + RADIUS ) &gt;= topPosition.y - ( WALL_WIDTH / 2 ) &amp;&amp;<br />
&nbsp; &nbsp; &nbsp; direction.y &gt; 0 )&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; // place the Pac on the top wall<br />
&nbsp; &nbsp; &nbsp; nodePtr-&gt;setPosition( position.x,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  ( topPosition.y - ( WALL_WIDTH / 2 ) - RADIUS ), position.z );<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp;  } // end else<br />
<br />
&nbsp;<br />
&nbsp;} // end function movePac<br />
<br />
<br />
void PacPersonObj::reverseHorizontalDirection()<br />
&nbsp;{<br />
&nbsp; &nbsp; direction *= Vector3( -1, 1, 1 ); // reverse the horizontal direction<br />
&nbsp;} // end function reverseHorizontalDirection<br />
<br />
&nbsp;// reverse the Ball's vertical direction<br />
&nbsp;void PacPersonObj::reverseVerticalDirection()<br />
&nbsp;{<br />
&nbsp; &nbsp; direction *= Vector3( 1, -1, 1 ); // reverse the vertical direction<br />
&nbsp;} // end function reverseVerticalDirection</pre><br />
Class that implements<br />
<br />
</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>luskbo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241683.html</guid>
		</item>
		<item>
			<title>measurement function</title>
			<link>http://www.daniweb.com/forums/thread241664.html</link>
			<pubDate>Thu, 26 Nov 2009 21:24:56 GMT</pubDate>
			<description>hi, 
i need to create function that mesaure time in micro second . 
how can i do it??? 
 
hezi</description>
			<content:encoded><![CDATA[<div>hi,<br />
i need to create function that mesaure time in micro second .<br />
how can i do it???<br />
<br />
hezi</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>HROFE</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241664.html</guid>
		</item>
		<item>
			<title>Functions - Fuelconsumption</title>
			<link>http://www.daniweb.com/forums/thread241663.html</link>
			<pubDate>Thu, 26 Nov 2009 21:22:45 GMT</pubDate>
			<description>Hi! 
 
I am doing a C++-program which I have to use functions. 
 
The program is the following: 
 
Write a function that calculates the fuelconsumption, it takes two numbers, litres and kilometers, and gives the consumption in litre per 100 km. The functions must write on screen in main. 
 
Here is...</description>
			<content:encoded><![CDATA[<div>Hi!<br />
<br />
I am doing a C++-program which I have to use functions.<br />
<br />
The program is the following:<br />
<br />
Write a function that calculates the fuelconsumption, it takes two numbers, litres and kilometers, and gives the consumption in litre per 100 km. The functions must write on screen in main.<br />
<br />
Here is what I have now:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;<br />
<br />
double fuelconsumption(int litre, kilometer);<br />
<br />
---------------------------------------------------------------------------<br />
<br />
int main()<br />
{&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
int gas;<br />
cout &lt;&lt; &quot;How much gas has been used: &quot; &lt;&lt; endl;<br />
cin &gt;&gt; liter;<br />
cout &lt;&lt; &quot;How many kilomoters have you driven: &quot; &lt;&lt; endl;<br />
cin &gt;&gt; kilometer;<br />
double gas = fuelconsumption(liter, kilometer);<br />
cout &lt;&lt; &quot;The fuelconsumption is &quot; &lt;&lt; gas &lt;&lt; &quot; litre per 100 km.&quot;;<br />
cout &lt;&lt; endl &lt;&lt; endl;<br />
<br />
return 0;<br />
}<br />
<br />
---------------------------------------------------------------------------<br />
<br />
double fuelconsumption(int litre, kilometer)<br />
{<br />
<br />
double gas = litre / kilometer;<br />
<br />
return gas;<br />
}</pre><br />
Thanks in advance!<br />
<br />
//Adam</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>foxmulder</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241663.html</guid>
		</item>
		<item>
			<title>Asterix Triangle help.</title>
			<link>http://www.daniweb.com/forums/thread241660.html</link>
			<pubDate>Thu, 26 Nov 2009 20:48:35 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>C++ Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">void triangle(ostream &amp;outs, unsigned int m, unsigned int n)<br />
{<br />
if ( m &lt;= n)<br />
{<br />
int NumberOfLines = (2 * (( n - m) + 1));<br />
int Mid = (NumberOfLines / 2);<br />
for (int i = 0; i &lt; NumberOfLines; i++)<br />
{<br />
if (i &lt; Mid)<br />
{<br />
for (int j = i; j &lt; n; j++)<br />
outs &lt;&lt; &quot;*&quot;;<br />
}<br />
else<br />
{<br />
for (int j = 0; j &lt; (m + (i - Mid)); j++)<br />
outs &lt;&lt; &quot;*&quot;;<br />
}<br />
outs &lt;&lt; endl;<br />
}<br />
}<br />
else<br />
outs &lt;&lt; &quot;Value m cannot be greater than n.&quot; &lt;&lt; endl;<br />
}</pre>it comes out opposite of what i want it to do.<br />
it looks like this.<br />
****<br />
***<br />
**<br />
**<br />
***<br />
****<br />
but I want it to look like this.<br />
**<br />
***<br />
****<br />
****<br />
***<br />
**</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>sabian4k</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241660.html</guid>
		</item>
		<item>
			<title>How to store unique elements</title>
			<link>http://www.daniweb.com/forums/thread241657.html</link>
			<pubDate>Thu, 26 Nov 2009 20:43:44 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I have a 2 dimensional vector containing entries such as : 
 
10X 
01X 
001 
 
I merge two rows at a time and get a new row of elements.  In other words, when i combine "10X" and "01X" i might get "001" but since "001" is already there i do not want to add it to the 2D vector.]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I have a 2 dimensional vector containing entries such as :<br />
<br />
10X<br />
01X<br />
001<br />
<br />
I merge two rows at a time and get a new row of elements.  In other words, when i combine &quot;10X&quot; and &quot;01X&quot; i might get &quot;001&quot; but since &quot;001&quot; is already there i do not want to add it to the 2D vector. <br />
<br />
I think &quot;Set&quot; will allow me to store unique elements. But i do not know how to define a Set for this. <br />
<br />
Any help is appreciated.<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>guest7</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241657.html</guid>
		</item>
		<item>
			<title>How to check if a named pipe(file) is empty</title>
			<link>http://www.daniweb.com/forums/thread241653.html</link>
			<pubDate>Thu, 26 Nov 2009 20:18:51 GMT</pubDate>
			<description><![CDATA[I need to check if a named pipe is empty.  I am cycling through about 10 of them and if its empty I don't want to block until there is something in it I just want to move on to the next one.  Is there any way to check if the named pipe is empty before I read?  Its just a file and I have a file...]]></description>
			<content:encoded><![CDATA[<div>I need to check if a named pipe is empty.  I am cycling through about 10 of them and if its empty I don't want to block until there is something in it I just want to move on to the next one.  Is there any way to check if the named pipe is empty before I read?  Its just a file and I have a file descriptor so checking the file would probably work as well.  I can't seem to find a way to do this on google.<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>chunalt787</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241653.html</guid>
		</item>
		<item>
			<title>Remove dublettes from a List</title>
			<link>http://www.daniweb.com/forums/thread241643.html</link>
			<pubDate>Thu, 26 Nov 2009 19:40:29 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I wonder what the way is to remove dublettes from a List. ? 
I have filled a List like this: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox"...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I wonder what the way is to remove dublettes from a List. ?<br />
I have filled a List like this:<br />
<br />
 <pre style="margin:20px; line-height:13px">List&lt;String^&gt;^ List1 = gcnew List&lt;String^&gt;();<br />
<br />
List1-&gt;Add(&quot;123&quot;);<br />
List1-&gt;Add(&quot;124&quot;);<br />
List1-&gt;Add(&quot;123&quot;);</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Darth Vader</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241643.html</guid>
		</item>
		<item>
			<title>Where to Start, Confused</title>
			<link>http://www.daniweb.com/forums/thread241638.html</link>
			<pubDate>Thu, 26 Nov 2009 19:13:50 GMT</pubDate>
			<description><![CDATA[*Description* 
I want to have a video conference system. 
1. That is the client-server model. 
2. The client can send audio/video/document(like ppt.doc.xls..)/application sharing/chat functions. 
3. The client's window can receive 16 videos(from other clients). 
4. The client can work on windows...]]></description>
			<content:encoded><![CDATA[<div><span style="font-weight:bold">Description</span><br />
I want to have a video conference system.<ol style="list-style-type: decimal"><li>That is the client-server model.</li>
<li>The client can send audio/video/document(like ppt.doc.xls..)/application sharing/chat functions.</li>
<li>The client's window can receive 16 videos(from other clients).</li>
<li>The client can work on windows platform.</li>
<li>The server can work on windows or linux(it's better).</li>
<li>The video can support 160*120/320*240/640*480...</li>
</ol><br />
I copied this description from <a rel="nofollow" class="t" href="http://www.getafreelancer.com/projects/C-C-Java/Video-Conferencing-Software-development.html" target="_blank">Here</a><br />
The problem is, when i read such a description i completely get confused that how and where to start.<br />
Suppose this task is assigned me to complete, so please provide me the guide lines where to start.<br />
<br />
I know windows API little bit and made small projects during study session, but i don't know how to render video on the Window.<br />
<br />
Question is: What i need to know to complete this project??<br />
<br />
Thanks..</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>AbsoluteCPP</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241638.html</guid>
		</item>
		<item>
			<title>trouble with if else statements</title>
			<link>http://www.daniweb.com/forums/thread241635.html</link>
			<pubDate>Thu, 26 Nov 2009 19:03:40 GMT</pubDate>
			<description><![CDATA[I have 2 main if statements inside this for loop (lines 7 and 56). I'm trying to get so that if after all the iterations are complete, i.e. j = 51 the first and second if statements are not satisfied, then it will print out an error message. I have currently tried to do this with another if else...]]></description>
			<content:encoded><![CDATA[<div>I have 2 main if statements inside this for loop (lines 7 and 56). I'm trying to get so that if after all the iterations are complete, i.e. j = 51 the first and second if statements are not satisfied, then it will print out an error message. I have currently tried to do this with another if else statement, however at the moment this is getting printed out no matter what.<br />
<br />
Can anyone please explain how to do this?<br />
<br />
 <pre style="margin:20px; line-height:13px"> <br />
<br />
for (double j = -50; j &lt;= 51; j=j+0.1)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; f(B, j, p, degree);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( f(B, j, p, degree) &lt;= 0 &amp;&amp; f(B, j+0.1, p, degree) &gt; 0 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\nA root is between the interval (&quot; &lt;&lt; j &lt;&lt;&quot;,&quot;&lt;&lt; j+1 &lt;&lt;&quot;)&quot;&lt;&lt;endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left_endpoint = j;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x1 = left_endpoint;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f1 = f(B, x1, p, degree);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; right_endpoint = j+1;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmid = right_endpoint;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmid = f(B, xmid, p, degree);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width = (right_endpoint - left_endpoint);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 1; i &lt;= max; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2 = (x1 + xmid) / 2.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The next midpoint, approximation is &quot; &lt;&lt;fixed&lt;&lt;setprecision(7)&lt;&lt; x2 &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f2 = f(B, x2, p, degree);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (f1 * f2 &lt;= 0.0) // root is in left half interval<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current_width = (x2 - x1) / 2.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmid = f2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmid = x2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else // root is in right half interval<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current_width = (xmid - x2) / 2.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f1 = f2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x1 = x2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (current_width &lt; epsilon)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\nA root at x = &quot; &lt;&lt; x2 &lt;&lt; &quot; was found &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;in &quot; &lt;&lt; i &lt;&lt; &quot; iterations&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f2 = f(B, x2, p, degree);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The value of the function at the root is &quot; &lt;&lt; f2 &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if ( f(B, j, p, degree) &gt;= 0 &amp;&amp; f(B, j+0.1, p, degree) &lt; 0 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\nA root is between the interval (&quot; &lt;&lt; j &lt;&lt;&quot;,&quot;&lt;&lt; j+1 &lt;&lt;&quot;)&quot;&lt;&lt;endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left_endpoint = j;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x1 = left_endpoint;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f1 = f(B, x1, p, degree);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; right_endpoint = j+1;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmid = right_endpoint;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmid = f(B, xmid, p, degree);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width = (right_endpoint - left_endpoint);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 1; i &lt;= max; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2 = (x1 + xmid) / 2.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The next midpoint, approximation is &quot; &lt;&lt;fixed&lt;&lt;setprecision(7)&lt;&lt; x2 &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f2 = f(B, x2, p, degree);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (f1 * f2 &lt;= 0.0) // root is in left half interval<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current_width = (x2 - x1) / 2.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fmid = f2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmid = x2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else // root is in right half interval<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current_width = (xmid - x2) / 2.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f1 = f2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x1 = x2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (current_width &lt; epsilon)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\nA root at x = &quot; &lt;&lt; x2 &lt;&lt; &quot; was found &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;in &quot; &lt;&lt; i &lt;&lt; &quot; iterations&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f2 = f(B, x2, p, degree);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The value of the function at the root is &quot; &lt;&lt; f2 &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (j = 51)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\nThe search for a root has failed. The polynomial you have entered&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;\ncontains one or more complex roots.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>sexyzebra19</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241635.html</guid>
		</item>
		<item>
			<title>Adding Large Integers</title>
			<link>http://www.daniweb.com/forums/thread241634.html</link>
			<pubDate>Thu, 26 Nov 2009 18:57:35 GMT</pubDate>
			<description>I have to creat a program where the user inputs two large ints, and they are converted into string in order to add them together (assuming they are larger than 20 characters).  One thing, is that it tells me to convert the numbers to a string and store it in reverse order....how do I do this?</description>
			<content:encoded><![CDATA[<div>I have to creat a program where the user inputs two large ints, and they are converted into string in order to add them together (assuming they are larger than 20 characters).  One thing, is that it tells me to convert the numbers to a string and store it in reverse order....how do I do this?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>PDB1982</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241634.html</guid>
		</item>
		<item>
			<title>Calling member function</title>
			<link>http://www.daniweb.com/forums/thread241630.html</link>
			<pubDate>Thu, 26 Nov 2009 18:14:34 GMT</pubDate>
			<description><![CDATA[Hi! 
 
I'm still new to C++ programming and I'm currently writing a plugin for a visual-effects application. I create a point, which is generated by the member function of a different class. Here is an excerpt of my source code 
 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hi!<br />
<br />
I'm still new to C++ programming and I'm currently writing a plugin for a visual-effects application. I create a point, which is generated by the member function of a different class. Here is an excerpt of my source code<br />
<br />
 <pre style="margin:20px; line-height:13px">void create_geometry(Scene&amp; scene, GeometryList&amp; out)<br />
{<br />
out.add_primitive(obj, new Point(Point::SPHERE, 300.0f, i));<br />
}</pre><br />
The Point class has a member function which is called render_mode(int v); and I want to call this member function for the Point object that just got created. But how do I do this without knowing which name that object got? Normally I would do something like myPoint.render_mode(true);. But that is not possible for this case right?<br />
I'd appreciate any help!<br />
<br />
Phong</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>nhatphongtran</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241630.html</guid>
		</item>
		<item>
			<title>memory leak</title>
			<link>http://www.daniweb.com/forums/thread241627.html</link>
			<pubDate>Thu, 26 Nov 2009 17:43:59 GMT</pubDate>
			<description><![CDATA[Hi everyone, I write a project about a banking system . In homework professor told us that "Your code must not have any memory leaks. You will lose points if you have memory leaks in your program even though the outputs of the operations are correct." How can I check whether my code has memory leak...]]></description>
			<content:encoded><![CDATA[<div>Hi everyone, I write a project about a banking system . In homework professor told us that &quot;Your code must not have any memory leaks. You will lose points if you have memory leaks in your program even though the outputs of the operations are correct.&quot; How can I check whether my code has memory leak or not?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>jacline</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241627.html</guid>
		</item>
		<item>
			<title>New to MFC. Console app to GUI</title>
			<link>http://www.daniweb.com/forums/thread241625.html</link>
			<pubDate>Thu, 26 Nov 2009 17:32:02 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I've been learning C++ these last few months, but never tried to make a GUI before. 
 
I've wrote a program in C++ which works via the command line, but now I'm trying to create a GUI for it (MFC using Visual Studio 2005, XP host). 
 
When I add an Edit Box to the form, then add a variable...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I've been learning C++ these last few months, but never tried to make a GUI before.<br />
<br />
I've wrote a program in C++ which works via the command line, but now I'm trying to create a GUI for it (MFC using Visual Studio 2005, XP host).<br />
<br />
When I add an Edit Box to the form, then add a variable to the Edit Box, it's automatically creates a variable of type Cstring.<br />
<br />
In my program I'm using strings (#include &lt;string&gt;).<br />
<br />
Is there any problem with me simply adding the #include for strings and altering the code from CString to string?<br />
<br />
This might sound silly, but adding the form has added sooo much code which I hardly understand and so I don't want to break it!<br />
<br />
Thanks for any advice!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Carrots</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241625.html</guid>
		</item>
		<item>
			<title>C++ Qt Framework</title>
			<link>http://www.daniweb.com/forums/thread241624.html</link>
			<pubDate>Thu, 26 Nov 2009 17:28:34 GMT</pubDate>
			<description><![CDATA[Hallo All, 
 
I am a beginner in C++ and currently need help in finishing the following task: 
 
I need to write an UDP code(C++) which sends and receives a random number (between 0 to 100). On the receiver's side there must be an User Interface showing the number received graphically. Graphically...]]></description>
			<content:encoded><![CDATA[<div>Hallo All,<br />
<br />
I am a beginner in C++ and currently need help in finishing the following task:<br />
<br />
I need to write an UDP code(C++) which sends and receives a random number (between 0 to 100). On the receiver's side there must be an User Interface showing the number received graphically. Graphically means say I received number 50 then the User interface must have something like an analog clock with values starting from 0 to 100 (like 0,10,20,30,40 ...100) and only one hand(like minute hand). Depending upon the number received the hand should point that particular number.<br />
<br />
I think I can use Qt for UI but dont know how to use custom widgets and also how to move the hand based on the number received.<br />
<br />
Can anybody please help me. Thanks in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>thisismyuname</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241624.html</guid>
		</item>
		<item>
			<title>Reading files</title>
			<link>http://www.daniweb.com/forums/thread241623.html</link>
			<pubDate>Thu, 26 Nov 2009 17:19:50 GMT</pubDate>
			<description><![CDATA[Hi *, 
 
I have a file like this : 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div>...]]></description>
			<content:encoded><![CDATA[<div>Hi *,<br />
<br />
I have a file like this :<br />
<br />
 <pre style="margin:20px; line-height:13px">Example :<br />
10 2<br />
0 1 234.5677<br />
0 2 345.6786<br />
0 3 678.6764<br />
....</pre><br />
From the first line the first number is number of lines and the second one is the number of nodes, so the thing is I need to extract those numbers first and then fill a matrix with the rest of the lines.<br />
<br />
I can not extract just the first line get the numbers and initialiaze my matrix object and after fill it. I have the following code :<br />
<br />
I read the file, get a line put it in a stream to split it and get the two numbers, aftet that  I want to fill a matrix with the rest.<br />
<br />
I am using a variable called lines that tells me if I am getting the first line or not, so if I am getting the first line I get the numbers and initialize my matrix object, if not I fill the matrix because I am reading the rest of the file. <br />
<br />
I think :<br />
<br />
1.- That is not the best way to do it<br />
2.- It returns me <br />
 <pre style="margin:20px; line-height:13px">In member function ‘void Instance::getNewInstance(std::string)’:<br />
Instance.cpp:78: error: ‘data’ was not declared in this scope</pre>which is expected because I am initializing my matrix object inside the conditional (if) and filling it in the else case.<br />
3.- Is there a way to read the first line and keep the pointer to that line in order to read the rest of the file inside a loop?. In python (for example) you can get the first line and after the rest of the lines inside a loop.<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">if (file.is_open()) // Open file operation succees<br />
&nbsp; {<br />
&nbsp; &nbsp; while (! file.eof())&nbsp; // to end of the file!<br />
&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; getline(file,line); // read each line <br />
&nbsp; &nbsp; &nbsp; stringstream ss(line); // put line in a stream<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; while (ss &gt;&gt; buf) // reading putting each string in buf<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; tokens.push_back(buf); // putting each value in a vector<br />
&nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; if (lines == 0) // this means first line n and m<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; setN(atoi(tokens[0].c_str())); // n and m values are going to be used after<br />
&nbsp; &nbsp; &nbsp; &nbsp; setM(atoi(tokens[1].c_str()));<br />
&nbsp; &nbsp; &nbsp; &nbsp; int size = getN();<br />
&nbsp; &nbsp; &nbsp; &nbsp; MatrixHandler data(size,size);<br />
&nbsp; &nbsp; &nbsp; } else { // rest of the lines<br />
&nbsp; &nbsp; &nbsp; &nbsp; int from;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int to;<br />
&nbsp; &nbsp; &nbsp; &nbsp; from = atoi(tokens[0].c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; to = atoi(tokens[1].c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; data.setMatrixValue(from,to,atof(tokens[2].c_str()));<br />
&nbsp; &nbsp; &nbsp; &nbsp; data.setMatrixValue(to,from,atof(tokens[2].c_str()));<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;From &quot; &lt;&lt; setprecision(8) &lt;&lt; from &lt;&lt; &quot; &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;To &quot; &lt;&lt; setprecision(8) &lt;&lt; to &lt;&lt; &quot; &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Cost &quot; &lt;&lt; setprecision(8) &lt;&lt; atof(tokens[2].c_str()) &lt;&lt; &quot; &quot; &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; tokens.clear();<br />
&nbsp; &nbsp; &nbsp; lines = 1;<br />
&nbsp; &nbsp; } <br />
&nbsp; &nbsp; file.close();<br />
&nbsp; &nbsp; //cout &lt;&lt; setprecision(8) &lt;&lt; atof(tokens[2].c_str()) &lt;&lt; endl;<br />
&nbsp; &nbsp; //cout &lt;&lt; setprecision(9) &lt;&lt; data.getMatrixValue(1,2) &lt;&lt; endl;<br />
&nbsp; }<br />
&nbsp; else cout &lt;&lt; &quot;File&quot; &lt;&lt; fileName &lt;&lt; &quot;can not be opened&quot; &lt;&lt; endl;</pre><br />
I hope to explain my case correctly.<br />
<br />
Thanks in advanced and best regards.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>fjrivash</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241623.html</guid>
		</item>
		<item>
			<title>Program not writing to file at all</title>
			<link>http://www.daniweb.com/forums/thread241620.html</link>
			<pubDate>Thu, 26 Nov 2009 16:22:07 GMT</pubDate>
			<description><![CDATA[This program has been bugging me a lot to get working, so far I've had to fight through tons of errors Hydra style (every one I got rid of, 2 took its place). Then I finally got an error free compile, but the txt file where the answers should be was sadly empty. After more messing around, I got...]]></description>
			<content:encoded><![CDATA[<div>This program has been bugging me a lot to get working, so far I've had to fight through tons of errors Hydra style (every one I got rid of, 2 took its place). Then I finally got an error free compile, but the txt file where the answers should be was sadly empty. After more messing around, I got this crazy new error that doesn't show up on compile, rather it shows up while the program is running.<br />
<br />
This program is designed to take a bunch of students and grades from the file &quot;data.txt&quot;, manipulate the scores to get a final grade, and display the test average, homework average, and final grade, as well as a tally of how many of each grade the class got, in the file &quot;out.txt&quot;.<br />
<br />
Code time.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;iomanip&gt;<br />
<br />
using namespace std;<br />
struct studentType<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; string idno;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double test[2];<br />
&nbsp; &nbsp; &nbsp; &nbsp; double a[7];<br />
};<br />
<br />
studentType studentData[30];<br />
double hwsum;<br />
double testsum;<br />
double hwavg;<br />
double testavg;<br />
double finalavg;<br />
int finalavg2;<br />
char grade;<br />
int acount;<br />
int bcount;<br />
int ccount;<br />
int dcount;<br />
int ecount;<br />
int read;<br />
int index = 0;<br />
ofstream outfile;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int getInput(studentType studentData[30], ifstream&amp; indata, ifstream&amp; infile);<br />
&nbsp; &nbsp; &nbsp; &nbsp; void process(studentType studentData[30]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; void display(const studentType studentData[30], ofstream&amp; outfile);<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream infile;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream indata;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outfile &lt;&lt; &quot;STUDENT ID&nbsp; HW AVE&nbsp; TEST AVE&nbsp; FINAL SCORE&nbsp; GRADE&quot; &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; getInput(studentData, indata, infile);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; outfile &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; outfile &lt;&lt; &quot;Number of A's: &quot; &lt;&lt; acount &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; outfile &lt;&lt; &quot;Number of B's: &quot; &lt;&lt; bcount &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; outfile &lt;&lt; &quot;Number of C's: &quot; &lt;&lt; ccount &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; outfile &lt;&lt; &quot;Number of D's: &quot; &lt;&lt; dcount &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; outfile &lt;&lt; &quot;Number of E's: &quot; &lt;&lt; ecount &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; infile.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; outfile.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
int getInput(studentType studentData[30], ifstream&amp; indata, ifstream&amp; infile)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; infile.open(&quot;data.txt&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(!infile.eof())<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; indata &gt;&gt; studentData[index].idno &gt;&gt; studentData[index].test[0] &gt;&gt; studentData[index].test[1] &gt;&gt; studentData[index].a[0] &gt;&gt; studentData[index].a[1] &gt;&gt; studentData[index].a[2] &gt;&gt; studentData[index].a[3] &gt;&gt; studentData[index].a[4] &gt;&gt; studentData[index].a[5] &gt;&gt; studentData[index].a[6];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; process(studentData);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; read += 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index += 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return read;<br />
}<br />
<br />
void process(studentType studentData[30])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int entry;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (entry = 0; entry &lt; 2; entry++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testsum += studentData[index].test[entry];<br />
&nbsp; &nbsp; &nbsp; &nbsp; testavg = testsum / 2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (entry = 0; entry &lt; 7; entry++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hwsum += studentData[index].a[entry];<br />
&nbsp; &nbsp; &nbsp; &nbsp; hwavg = hwsum / 7;<br />
&nbsp; &nbsp; &nbsp; &nbsp; finalavg = (testavg * .6) + (hwavg * .4);<br />
&nbsp; &nbsp; &nbsp; &nbsp; finalavg2 = finalavg;<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(finalavg2 / 10)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 4:<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 5:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grade = 'E';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ecount += 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 6:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grade = 'D';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dcount += 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 7:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grade = 'C';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ccount += 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 8:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grade = 'B';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bcount += 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 9:<br />
&nbsp; &nbsp; &nbsp; &nbsp; case 10:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grade = 'A';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acount += 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; default:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;???&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; display(studentData, outfile);<br />
<br />
}<br />
<br />
void display(const studentType studentData[30], ofstream&amp; outfile)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; outfile.open(&quot;out.txt&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; outfile &lt;&lt; setw(11) &lt;&lt; studentData[index].idno &lt;&lt; setw(8) &lt;&lt; hwavg &lt;&lt; setw(10) &lt;&lt; testavg &lt;&lt; setw(13) &lt;&lt; finalavg &lt;&lt; setw(7) &lt;&lt; grade &lt;&lt; endl;<br />
}</pre><br />
First thing to do right now, is get rid of this new error that's been bugging me. It compiles fine, but then the program displays a bunch of rows of &quot;???&quot;s, and a box pops up saying this:<br />
<br />
&quot;Unhandled exception at 0x009c1cea in Assignment4.exe: 0xC0000005: Access violation reading location 0x009d3000.&quot;<br />
<br />
Then it points to this line: <br />
<br />
&quot;testsum += studentData[index].test[entry];&quot; (line 76)<br />
<br />
Closing that out and hovering my mouse over some of the variables around there, I get this.<br />
<br />
entry = 1<br />
index = 232 (I'm guessing this is the problem, but I have no clue why it's happening)<br />
<br />
Checking some of the variables I'm supposedly getting from the file, the first two variables (idno and test[0]) are &quot;&quot; and 0 respectivly. But the rest of them have this weird value of &quot;0x009d3008&quot;. The text files that I'm using are in the right folder, so that isn't a problem.<br />
<br />
I have no clue what to do to solve these problems I'm having, I'm pretty confident that if I can just get it to read and write correctly, it should give the right answers, but getting to that point has been heck so far, and I need to have this done by midnight tomorrow.<br />
<br />
So if any kind soul is able to help me in any way, I would appreciate it very much.<br />
<br />
EDIT: Minor breakthrough here, the error no longer comes up after I changed &quot;indata&quot; to &quot;infile&quot; in line 65. Now the program displays 8 rows of ??? and finishes running. But still nothing has gone to the text file.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>cousinoer5</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241620.html</guid>
		</item>
		<item>
			<title>Making functions (a problem)</title>
			<link>http://www.daniweb.com/forums/thread241613.html</link>
			<pubDate>Thu, 26 Nov 2009 15:28:02 GMT</pubDate>
			<description>Hello again :) 
 
I had this project (first block of codes below) and out of this program i have to do the same again but this time using functions. 
 
My problem now is, i made some functions ( i hope these are functions) but on the last part (the one with the if else statements) i receive error...</description>
			<content:encoded><![CDATA[<div>Hello again :)<br />
<br />
I had this project (first block of codes below) and out of this program i have to do the same again but this time using functions.<br />
<br />
My problem now is, i made some functions ( i hope these are functions) but on the last part (the one with the if else statements) i receive error messages.<br />
<br />
Maybe one of you knows what i did wrong there. (Second block of codes below)<br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
<br />
using namespace std;<br />
<br />
main()<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; string name, course[10];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int x, y, n; <br />
&nbsp; &nbsp; &nbsp; &nbsp; float grade[10];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char response;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Please enter your name: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; name;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Please enter number of subjects: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Hello &quot; &lt;&lt; name &lt;&lt; &quot; you have &quot; &lt;&lt; y &lt;&lt; &quot; subjects.&quot; &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; n=1;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int a=0; a&lt;y; a++)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Please enter your course &quot; &lt;&lt; n &lt;&lt; &quot;:&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; course[a];<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Please enter your Grade: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; grade[a];<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; n++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Course\tGrade\tEquivalent\tRemarks&nbsp; &quot; &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int ctr=0;ctr&lt;y;ctr++)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (grade[ctr] &gt; 5.0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr] &lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t75%\ - lower \t Failed&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] == 3.0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr] &lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t75% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=2.75)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr] &lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t78% \t\t passed&quot;&lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] =2.5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t81% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=2.25)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t84% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=2.0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t87% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=1.75)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t90% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=1.5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t\t 93%\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=1.25)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t96% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] ==1.0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt;&nbsp; grade[ctr] &lt;&lt; &quot;\t100% \t\t passed&quot;&lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;invalid input of grade&quot;&lt;&lt; endl;<br />
}&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; response;<br />
<br />
return 0;<br />
<br />
}</pre><br />
BLOCK 2<br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
<br />
using namespace std;<br />
<br />
<br />
void EnterName ()<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Enter your name: &quot;;<br />
<br />
}<br />
<br />
void EnterSubject ()<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Enter the number of subjects: &quot;;<br />
<br />
}<br />
<br />
void Greetings (double x, double y)<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Hello &quot; &lt;&lt; x &lt;&lt; &quot; you have &quot; &lt;&lt; y &lt;&lt; &quot; subjects.&quot;;<br />
<br />
}<br />
<br />
void EnterCourse (int n)<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Please enter your course &quot; &lt;&lt; n &lt;&lt; &quot;:&quot;;<br />
<br />
}<br />
<br />
void EnterGrade ()<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Please enter your Grade: &quot;;<br />
<br />
}<br />
<br />
void Titel ()<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Course\tGrade\tEquivalent\tRemarks&nbsp; &quot; &lt;&lt; endl;<br />
<br />
}<br />
<br />
void Evaluation (float grade, string course[10], int ctr)<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (grade[ctr] &gt; 5.0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr] &lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t75%\ - lower \t Failed&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] == 3.0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr] &lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t75% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=2.75)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr] &lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t78% \t\t passed&quot;&lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] =2.5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t81% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=2.25)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t84% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=2.0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t87% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=1.75)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t90% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=1.5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t\t 93%\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] &lt;=1.25)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt; grade[ctr] &lt;&lt; &quot;\t96% \t\t passed&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade[ctr] ==1.0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course[ctr]&lt;&lt; &quot;\t&quot; &lt;&lt;&nbsp; grade[ctr] &lt;&lt; &quot;\t100% \t\t passed&quot;&lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;invalid input of grade&quot;&lt;&lt; endl;<br />
<br />
}<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; main()<br />
<br />
{<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; string name, course[10];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int a, b, c, x, y, n; <br />
&nbsp; &nbsp; &nbsp; &nbsp; float grade[10];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char response;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void EnterName ()<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; name;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void EnterSubject ()<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; y;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void Greetings (double b, double c)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; n=1;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int a=0; a&lt;y; a++)<br />
{<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void EnterCourse ()<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; course[a];<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void EnterGrade ()<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; grade[a];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void Titel ()<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int ctr=0;ctr&lt;y;ctr++)<br />
{<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void Evaluation (double x, double y)<br />
<br />
}&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; response;<br />
<br />
return 0;<br />
<br />
}</pre><br />
Thank you for taking your time for it.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>HelloMe</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241613.html</guid>
		</item>
		<item>
			<title>somebody please help me.please</title>
			<link>http://www.daniweb.com/forums/thread241610.html</link>
			<pubDate>Thu, 26 Nov 2009 15:21:59 GMT</pubDate>
			<description><![CDATA[i need to add virtual function to my coding. somebody please help. whre should i put it 
 
heres the code. 
_figure.h_  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680"...]]></description>
			<content:encoded><![CDATA[<div>i need to add virtual function to my coding. somebody please help. whre should i put it<br />
<br />
heres the code.<br />
<span style="text-decoration:underline">figure.h</span> <pre style="margin:20px; line-height:13px">//This is the header file figure.h. <br />
using std::cout;<br />
<br />
class figure<br />
{<br />
&nbsp; &nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  virtual void center();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void draw();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void erase();<br />
};<br />
<br />
void figure::center()<br />
{<br />
&nbsp; &nbsp;  cout &lt;&lt; &quot;Centering the Figure&quot;;<br />
&nbsp; &nbsp;  cout &lt;&lt; &quot;\n&quot;;<br />
&nbsp; &nbsp;  cout &lt;&lt; &quot;\n&quot;;</pre><span style="text-decoration:underline">rectangle.h</span><br />
 <pre style="margin:20px; line-height:13px">//This is the header file rectangle.h. <br />
using std::cout;<br />
<br />
class rectangle : public figure<br />
{<br />
&nbsp; &nbsp; &nbsp; public : void erase();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  l void draw();<br />
};<br />
<br />
<br />
void rectangle::draw()<br />
<br />
{<br />
&nbsp; &nbsp;  cout &lt;&lt; &quot;Drawing rectangle&quot;;<br />
}<br />
<br />
void rectangle::erase()<br />
<br />
{<br />
&nbsp; &nbsp;  cout &lt;&lt; &quot;Erasing rectangle&quot;;<br />
}</pre>triangle.h<br />
 <pre style="margin:20px; line-height:13px">//This is the header file triangle.h.<br />
using std::cout;<br />
<br />
class triangle : public figure<br />
{<br />
&nbsp; &nbsp; &nbsp; public :&nbsp; void erase();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void draw();<br />
};<br />
<br />
<br />
void triangle::draw()<br />
<br />
{<br />
&nbsp; &nbsp;  cout &lt;&lt; &quot;Drawing triangle&quot;;<br />
}<br />
<br />
void triangle::erase()<br />
<br />
{<br />
&nbsp; &nbsp;  cout &lt;&lt; &quot;Erasing triangle&quot;;<br />
}</pre><span style="text-decoration:underline">virtual.cpp</span><br />
 <pre style="margin:20px; line-height:13px">//This is the header file triangle.h.<br />
using std::cout;<br />
<br />
class triangle : public figure<br />
{<br />
&nbsp; &nbsp; &nbsp; public : virtual void erase();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  virtual void draw();<br />
};<br />
<br />
<br />
void triangle::draw()<br />
<br />
{<br />
&nbsp; &nbsp;  cout &lt;&lt; &quot;Drawing triangle&quot;;<br />
}<br />
<br />
void triangle::erase()<br />
<br />
{<br />
&nbsp; &nbsp;  cout &lt;&lt; &quot;Erasing triangle&quot;;<br />
}</pre><br />
<br />
please help me. asap. thankx in advance</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>misvampire</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241610.html</guid>
		</item>
		<item>
			<title>Filtering an array based on information in another array?</title>
			<link>http://www.daniweb.com/forums/thread241592.html</link>
			<pubDate>Thu, 26 Nov 2009 14:11:42 GMT</pubDate>
			<description><![CDATA[Just wondering if there was any kinda way of doing this kind of filtering based on comparison other than having to go through each position in an array one by one comparing it to every position in the other array. 
 
If I'm to vague and you need more information let me know.]]></description>
			<content:encoded><![CDATA[<div>Just wondering if there was any kinda way of doing this kind of filtering based on comparison other than having to go through each position in an array one by one comparing it to every position in the other array.<br />
<br />
If I'm to vague and you need more information let me know.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>edherbs135</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241592.html</guid>
		</item>
		<item>
			<title>Why need to define static</title>
			<link>http://www.daniweb.com/forums/thread241590.html</link>
			<pubDate>Thu, 26 Nov 2009 14:07:37 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>C++ Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">void main()<br />
{<br />
&nbsp;static int a[]={ 0,1,2,3,4}; // if here static removed that hence error why?<br />
&nbsp; &nbsp; &nbsp; &nbsp; int *p[]={ a,a+1,a+2,a+3,a+4};<br />
&nbsp; &nbsp; &nbsp; &nbsp; int **ptr=p;<br />
&nbsp; &nbsp; &nbsp; &nbsp; clrscr();<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot; base address is %u&quot;,a);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ptr++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
getch();<br />
&nbsp;}</pre><br />
in above code in &quot;staic int a[] &quot; line integer array define as static why it need?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kapil.muni1020</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241590.html</guid>
		</item>
		<item>
			<title>C++ HTML Parser</title>
			<link>http://www.daniweb.com/forums/thread241580.html</link>
			<pubDate>Thu, 26 Nov 2009 13:34:20 GMT</pubDate>
			<description><![CDATA[Hey everyone, Happy Thanksgiving first and foremost... 
 
Second, I am attempting to build my own HTML Parser in C++ but I have no idea where to start... 
 
I've looked at some of the examples and libraries out there on the web, but none of them really helped... 
 
If someone could just outline a...]]></description>
			<content:encoded><![CDATA[<div>Hey everyone, Happy Thanksgiving first and foremost...<br />
<br />
Second, I am attempting to build my own HTML Parser in C++ but I have no idea where to start...<br />
<br />
I've looked at some of the examples and libraries out there on the web, but none of them really helped...<br />
<br />
If someone could just outline a piece of code of point me to a tutorial on HTML parsing in C++ and I would take it from there...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>didijc</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241580.html</guid>
		</item>
		<item>
			<title>static const variable inside function</title>
			<link>http://www.daniweb.com/forums/thread241559.html</link>
			<pubDate>Thu, 26 Nov 2009 11:51:10 GMT</pubDate>
			<description><![CDATA[I declared this inside one function: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div>...]]></description>
			<content:encoded><![CDATA[<div>I declared this inside one function:<br />
 <pre style="margin:20px; line-height:13px">void function()<br />
{<br />
&nbsp; &nbsp; ....<br />
&nbsp; &nbsp; static const int iLimit = GetLimit();<br />
&nbsp; &nbsp; int iL = a_MyArray[iLimit];<br />
&nbsp; &nbsp; ....<br />
}</pre><br />
The code compiles ok in g++. What I want to know is whether the GetLimit function will be called only once (At the first call to function() ?). Plz help. Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>dumrat</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241559.html</guid>
		</item>
		<item>
			<title>xy graph of msChart control in vc++</title>
			<link>http://www.daniweb.com/forums/thread241542.html</link>
			<pubDate>Thu, 26 Nov 2009 10:30:38 GMT</pubDate>
			<description><![CDATA[can someone pls post some tutorials or articles on "how to use mschart for plotting xy graph in vc++". 
thanks in advance :)]]></description>
			<content:encoded><![CDATA[<div>can someone pls post some tutorials or articles on &quot;how to use mschart for plotting xy graph in vc++&quot;.<br />
thanks in advance :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>sush27</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241542.html</guid>
		</item>
		<item>
			<title>How do you ask user for input then display the information given back to the user?</title>
			<link>http://www.daniweb.com/forums/thread241517.html</link>
			<pubDate>Thu, 26 Nov 2009 09:10:50 GMT</pubDate>
			<description><![CDATA[For example Im trying to make the user input his name, last name, and salary and then make it display " First Name is" followed by what they put in as their first name "Last Name is" followed by what he put as his last name... and now im getting all sorts of errors 
 
Fairly new to this so any...]]></description>
			<content:encoded><![CDATA[<div>For example Im trying to make the user input his name, last name, and salary and then make it display &quot; First Name is&quot; followed by what they put in as their first name &quot;Last Name is&quot; followed by what he put as his last name... and now im getting all sorts of errors<br />
<br />
Fairly new to this so any information would be greatly appreciated<br />
<br />
Thanks for your time.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; string firstName;<br />
&nbsp; &nbsp; &nbsp; &nbsp; string lastName;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int salary;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::cout &lt;&lt; &quot;Enter First Name, Last Name, Salary&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::cin &gt;&gt; firstName &gt;&gt; lastName &gt;&gt; salary;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; std::cout &lt;&lt; &quot;\nFirst Name is &quot; &lt;&lt; firstName;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::cout &lt;&lt; &quot;\nLast Name is &quot; &lt;&lt; lastName;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::cout &lt;&lt; &quot;\nSalary is &quot; &lt;&lt; salary;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator><![CDATA["Alex"]]></dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241517.html</guid>
		</item>
		<item>
			<title>Can´t find the error</title>
			<link>http://www.daniweb.com/forums/thread241490.html</link>
			<pubDate>Thu, 26 Nov 2009 07:01:25 GMT</pubDate>
			<description>Hello everyone... 
 
I have a problem on the last part of my codes. 
This programm supposed to accept several kind of courses and its corresponding grades.  
So far so good... but when it comes to display the courses and the grades and its remarks of passed or failed, the programm gives me an error...</description>
			<content:encoded><![CDATA[<div>Hello everyone...<br />
<br />
I have a problem on the last part of my codes.<br />
This programm supposed to accept several kind of courses and its corresponding grades. <br />
So far so good... but when it comes to display the courses and the grades and its remarks of passed or failed, the programm gives me an error message. Actually it gives me 45 errors beginning with the first if else statement. <br />
<br />
Here are my codes so far:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
<br />
using namespace std;<br />
<br />
main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; string name, course&#91;10&#93;, grade&#91;10&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int x, y, n;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char response;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Please enter your name: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; name;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Please enter number of subjects: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Hello &quot; &lt;&lt; name &lt;&lt; &quot; you have &quot; &lt;&lt; y &lt;&lt; &quot; subjects.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; n=1;<br />
<br />
<br />
<br />
&nbsp; &nbsp; for(int a=1; a&lt;=y; a++)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Please enter your course &quot; &lt;&lt; n &lt;&lt; &quot;:&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; course&#91;x&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Please enter your Grade: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; grade&#91;x&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; n++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;Course&nbsp;  Grade&nbsp;  Remarks&nbsp; &quot; &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int ctr=1;ctr&lt;=y;ctr++)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (grade&#91;ctr&#93; &lt; 75)&nbsp; // &#91;COLOR=&quot;Red&quot;&#93;HERE THE FIRST ERROR&#91;/COLOR&#93; STARTS<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course&#91;x&#93;&lt;&lt; &quot;5.0\t FAILED&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade&#91;ctr&#93; ==75)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course&#91;x&#93;&lt;&lt; &quot;\t3.0\t passed&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade&#91;ctr&#93; &lt;=78)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course&#91;x&#93;&lt;&lt; &quot;\t2.75\t passed&quot;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade&#91;ctr&#93; =81)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course&#91;x&#93;&lt;&lt; &quot;\t2.5\t passed&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade&#91;ctr&#93; &lt;=84)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course&#91;x&#93;&lt;&lt; &quot;\t2.25\t passed&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade&#91;ctr&#93; &lt;=87)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course&#91;x&#93;&lt;&lt; &quot;\t2.0\t passed&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade&#91;ctr&#93; &lt;=90)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course&#91;x&#93;&lt;&lt; &quot;\t1.75\t passed&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade&#91;ctr&#93; &lt;=93)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course&#91;x&#93;&lt;&lt; &quot;\t1.5\t passed&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade&#91;ctr&#93; &lt;=96)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course&#91;x&#93;&lt;&lt; &quot;\t1.25 \t passed&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (grade&#91;ctr&#93; ==100)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; course&#91;x&#93;&lt;&lt; &quot;\t1.0\t passed&quot;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;invalid input of grade&quot;;<br />
}&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; response;<br />
<br />
return 0;<br />
<br />
}</pre><br />
If i set the if else statements in a comment block the programm runs ecxept the aoutput of course grade and remarks (pass/Failed).<br />
<br />
Would be grate if somebody can help me out.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>HelloMe</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241490.html</guid>
		</item>
		<item>
			<title><![CDATA[count even, odd, zero's]]></title>
			<link>http://www.daniweb.com/forums/thread241461.html</link>
			<pubDate>Thu, 26 Nov 2009 05:07:44 GMT</pubDate>
			<description><![CDATA[I have been working on this program to count the number of zero's odd, and even numbers that a user inputs. I have tried different variations and cannot get it to go, I keep getting linker errors and cannot see where the problem is. I am new to this and could really use the help. 
  <div...]]></description>
			<content:encoded><![CDATA[<div>I have been working on this program to count the number of zero's odd, and even numbers that a user inputs. I have tried different variations and cannot get it to go, I keep getting linker errors and cannot see where the problem is. I am new to this and could really use the help.<br />
 <pre style="margin:20px; line-height:13px">#include &quot;stdafx.h&quot;<br />
#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
<br />
void ClassifyNum(long remainder, long&amp; countZero, long&amp; countOdd, long&amp; countEven );<br />
void GetNum(long&amp; num);<br />
void Start(long remainder,long&amp; countZero, long&amp; countOdd, long&amp; countEven);<br />
<br />
using namespace std;<br />
<br />
<br />
int main( )<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; long number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int numCounter;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int userInput;<br />
&nbsp; &nbsp; &nbsp; &nbsp; long zero;<br />
&nbsp; &nbsp; &nbsp; &nbsp; long odd;<br />
&nbsp; &nbsp; &nbsp; &nbsp; long even;<br />
&nbsp; &nbsp; &nbsp; &nbsp; long remainder;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char userAnswer;<br />
<br />
<br />
<br />
do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Start(remainder,zero, odd, even);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter an number. &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; userInput;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (numCounter = 1; numCounter &lt;= userInput;numCounter++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetNum(number);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; number &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ClassifyNum(remainder, zero, odd, even);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Go again? (y/n). &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; userAnswer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
}while(userAnswer=='y');<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
void start(long remainder,long&amp; countZero, long&amp; countOdd, long&amp; countEven)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; remainder = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countZero = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countEven = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countOdd = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; void GetNum(long&amp; num)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; num;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; void ClassifyNum(long remainder, long&amp; countZero, long&amp; countOdd, long&amp; countEven)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; if (remainder == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countZero++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (remainder%2 == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countEven++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; countOdd++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>devo_99</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241461.html</guid>
		</item>
		<item>
			<title>How to write a program in C++ which balances chemical equations?</title>
			<link>http://www.daniweb.com/forums/thread241447.html</link>
			<pubDate>Thu, 26 Nov 2009 04:31:37 GMT</pubDate>
			<description>I am working on a equation balancer for my 12th class computer science project.But somehow i am not able to balance the chemical equation.Please if anyone can provide me the source code it will be a great help.Urgently needed!</description>
			<content:encoded><![CDATA[<div>I am working on a equation balancer for my 12th class computer science project.But somehow i am not able to balance the chemical equation.Please if anyone can provide me the source code it will be a great help.Urgently needed!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>coldkiller</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241447.html</guid>
		</item>
		<item>
			<title>How to do this simple question??</title>
			<link>http://www.daniweb.com/forums/thread241436.html</link>
			<pubDate>Thu, 26 Nov 2009 03:44:16 GMT</pubDate>
			<description>Hi....I got a simple question here which i dont know how to solve... 
 
*Question* 
Type casting is common in writing programs. It converts from one data type to another, for example from integer to double or float. Write a complete C++ program which uses casting, which will ask the quantity of...</description>
			<content:encoded><![CDATA[<div>Hi....I got a simple question here which i dont know how to solve...<br />
<br />
<span style="font-weight:bold">Question</span><br />
Type casting is common in writing programs. It converts from one data type to another, for example from integer to double or float. Write a complete C++ program which uses casting, which will ask the quantity of integers the program will receive from the user. The program will then ask the end user to enter series integers. The program will add up all of the integers, find its average and the multiplication of 2 of its average. Below is the sample output of the program. Please ensure your program is error proof (eg. you cannot enter -3 integers).<br />
<br />
How many integers do you want to enter? 3<br />
Please enter 3 integers separated by a space: 5 4 9<br />
The sum of the numbers is 18<br />
The average of the numbers is 6.00<br />
The multiplication of 2 of the average is 12.00<br />
<br />
<br />
How could i make the program that could limit the input integer the user try to enter,and how to make the program calculate the sum and all of that??I've tried to write the code,but i think there must be something that i need to know to write this which i dont know yet..could you tell me what it is??<br />
<br />
Thank you...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>samsons17</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241436.html</guid>
		</item>
		<item>
			<title>Array elements in Reverse order HELP!!</title>
			<link>http://www.daniweb.com/forums/thread241435.html</link>
			<pubDate>Thu, 26 Nov 2009 03:29:33 GMT</pubDate>
			<description><![CDATA[Here is the program: 
 
int i,n; 
	double v_in[20+1],v_out[20+1]; 
 
	cout << "\ninput n ? "; 
	cin >> n; 
	 
	for(i=1;i<=n;i++) { 
		cout << "input v_in[" << i << "] ? ";]]></description>
			<content:encoded><![CDATA[<div>Here is the program:<br />
<br />
int i,n;<br />
	double v_in[20+1],v_out[20+1];<br />
<br />
	cout &lt;&lt; &quot;\ninput n ? &quot;;<br />
	cin &gt;&gt; n;<br />
	<br />
	for(i=1;i&lt;=n;i++) {<br />
		cout &lt;&lt; &quot;input v_in[&quot; &lt;&lt; i &lt;&lt; &quot;] ? &quot;;<br />
		cin &gt;&gt; v_in[i];<br />
	}<br />
<br />
	<span style="font-weight:bold">// reverse v_in and store the result in v_out<br />
	for(i=1;i&lt;=n;i++) {<br />
		v_out[i] = v_in[n-i+1];</span><br />
	}<br />
<br />
	cout &lt;&lt; &quot;\nn = &quot; &lt;&lt; n;<br />
<br />
	cout &lt;&lt; &quot;\n\nv_in = &quot;;<br />
	for(i=1;i&lt;=n;i++) {<br />
		cout &lt;&lt; &quot;\n&quot; &lt;&lt; v_in[i];<br />
	}<br />
<br />
	cout &lt;&lt; &quot;\n\nv_out = &quot;;<br />
	for(i=1;i&lt;=n;i++) {<br />
		cout &lt;&lt; &quot;\n&quot; &lt;&lt; v_out[i];<br />
	}<br />
<br />
	cout &lt;&lt; &quot;\ndone.\n&quot;;<br />
	getch();<br />
<br />
	return 0; }<br />
<br />
Now in the Section in Bold, there's a part where he does this <br />
v_out[i] = v_in[n-i+1]<br />
What is the significance of n-i+1?? How does this reverse v_in???<br />
Please help??</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>momike205</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241435.html</guid>
		</item>
		<item>
			<title>Help in program</title>
			<link>http://www.daniweb.com/forums/thread241430.html</link>
			<pubDate>Thu, 26 Nov 2009 02:55:44 GMT</pubDate>
			<description><![CDATA[Hi  
while doing my homeworks, i stucked here .. 
Writting a program to calculate the factorial of positive integer . 
here is my code: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hi <br />
while doing my homeworks, i stucked here ..<br />
Writting a program to calculate the factorial of positive integer .<br />
here is my code:<br />
<br />
 <pre style="margin:20px; line-height:13px">int main ()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int x,factorial;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Enter an integer to calculate its factorial: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt;x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (x==1 &amp;&amp; x==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\nThe facotrial is: 1&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (x&lt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\nMath Error&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (x&gt;1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\nCalculating...&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; factorial = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (x&gt;1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; factorial = factorial * ( factorial - 1 );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x--;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\nThe facotrial is: &quot;&lt;&lt;factorial&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
I know there is an arithmetic error ..<br />
Thanks !</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Frap</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241430.html</guid>
		</item>
		<item>
			<title>Heapsort problems</title>
			<link>http://www.daniweb.com/forums/thread241420.html</link>
			<pubDate>Thu, 26 Nov 2009 02:14:13 GMT</pubDate>
			<description>My heapsort is not functioning the way it should, and I was wondering if perhaps one of you could help point me in the right direction. Much thanks in advance should you care to look! :) 
 
If it helps anyone, I posted it on pastebin.org with syntax highlighting: http://www.pastebin.org/55997 
...</description>
			<content:encoded><![CDATA[<div>My heapsort is not functioning the way it should, and I was wondering if perhaps one of you could help point me in the right direction. Much thanks in advance should you care to look! :)<br />
<br />
If it helps anyone, I posted it on pastebin.org with syntax highlighting: <a rel="nofollow" class="t" href="http://www.pastebin.org/55997" target="_blank">http://www.pastebin.org/55997</a><br />
<br />
Source code:<br />
 <pre style="margin:20px; line-height:13px">/******************************************************************************<br />
* Program:<br />
*&nbsp; &nbsp; &nbsp; &nbsp; Assignment 17, Heapsort Program<br />
* Summary: <br />
*&nbsp; &nbsp; &nbsp; &nbsp; From the command line, reads in a file containing numbers, placing the<br />
*&nbsp; &nbsp; &nbsp; &nbsp; numbers in a vector. The program performs a heap sort (a O(n log n)<br />
*&nbsp; &nbsp; &nbsp; &nbsp; sort) on the vector, and prints out the values.<br />
******************************************************************************/<br />
#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;vector&gt;<br />
using namespace std;<br />
<br />
///////////////////////////////////////////////////////////////////////////////<br />
// main<br />
///////////////////////////////////////////////////////////////////////////////<br />
<br />
/**** Prototypes used in main *****/<br />
vector &lt; int &gt; buildVector(string filename);<br />
void heapify(vector &lt; int &gt; &amp;tree, int wall);<br />
void percolateDown(vector &lt; int &gt; &amp;tree, int pos, int wall);<br />
void heapsort(vector &lt; int &gt; &amp;myVector);<br />
void display (const vector &lt; int &gt; &amp;myVector);<br />
<br />
/******************************************************************************<br />
* main<br />
* Desc:<br />
*&nbsp; &nbsp; &nbsp; &nbsp; From the command line, reads in a file containing numbers, placing the<br />
*&nbsp; &nbsp; &nbsp; &nbsp; numbers in a vector. The program performs a heap sort (a O(n log n)<br />
*&nbsp; &nbsp; &nbsp; &nbsp; sort) on the vector, and prints out the values.<br />
******************************************************************************/<br />
int main(int argc, char* argv[])<br />
{<br />
&nbsp;  string filename;<br />
&nbsp;  //Check for proper usage and invalid input<br />
&nbsp;  if (argc &lt;= 1 || argc &gt; 2)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Usage: &lt;executable&gt; &lt;file with numbers to be sorted&gt;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />
&nbsp;  }<br />
&nbsp;  else //input is good<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filename = argv[argc - 1];<br />
&nbsp;  }<br />
<br />
&nbsp;  vector &lt; int &gt; numbers = buildVector(filename); //build the number vector<br />
<br />
&nbsp;  cout &lt;&lt; &quot;Before:\n&quot;;<br />
&nbsp;  display(numbers);<br />
<br />
&nbsp;  heapsort(numbers);<br />
<br />
&nbsp;  cout &lt;&lt; &quot;After:\n&quot;;<br />
&nbsp;  display(numbers);<br />
<br />
&nbsp;  return 0;<br />
}<br />
<br />
/******************************************************************************<br />
* buildVector<br />
* Desc: Reads in a file with numbers, stores them in a vector, and returns<br />
*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  the vector of numbers.<br />
* Input: string filename containing the numbers<br />
* Return: vector myVector containing the numbers<br />
******************************************************************************/<br />
vector &lt; int &gt; buildVector(string filename)<br />
{<br />
&nbsp;  ifstream inStream;<br />
&nbsp;  vector &lt; int &gt; myVector;<br />
<br />
&nbsp;  //open file and check for success<br />
&nbsp;  inStream.open(filename.c_str());<br />
&nbsp;  if (inStream.fail()) //file failed to open<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unable to open file \&quot;&quot; &lt;&lt; filename<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;\&quot; in function buildVector()\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />
&nbsp;  }<br />
&nbsp;  else //successfully opened file<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int number; //numbers read in from file<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //push on all numbers from file onto vector<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (inStream &gt;&gt; number)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  myVector.push_back(number);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inStream.close();<br />
&nbsp;  }<br />
&nbsp;  return myVector;<br />
}<br />
<br />
/******************************************************************************<br />
* heapify<br />
* Desc: Transforms a complete binary tree into a heap (root is largest value).<br />
* Input: integer vector tree to heapify, int wall<br />
******************************************************************************/<br />
void heapify(vector &lt; int &gt; &amp;tree, int wall)<br />
{<br />
&nbsp;  int start = (wall - 2) / 2;<br />
&nbsp;  while (start &gt;= 0)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; percolateDown(tree, start, wall - 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --start;<br />
&nbsp;  }<br />
}<br />
<br />
/******************************************************************************<br />
* percolateDown<br />
* Desc: &quot;Percolates&quot; smaller values down to the bottom of the tree, creating<br />
*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  a maxheap.<br />
* Input: integer vector tree, int root (where we begin), int wall<br />
******************************************************************************/<br />
void percolateDown(vector &lt; int &gt; &amp;tree, int root, int wall)<br />
{<br />
&nbsp;  int child;<br />
&nbsp;  while ((2 * root + 1) &lt;= wall)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; child = 2 * root + 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (child + 1 &lt;= wall &amp;&amp; tree[child] &lt; tree[child + 1])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ++child;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (tree[root] &lt; tree[child])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int temp = tree[root];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  tree[root] = tree[child];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  tree[child] = temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  root = child;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
}<br />
<br />
/******************************************************************************<br />
* display<br />
* Desc: Displays the contents of a vector.<br />
* Input: Vector to be displayed<br />
******************************************************************************/<br />
void display (const vector &lt; int &gt; &amp;myVector)<br />
{<br />
&nbsp;  for (int i = 0; i &lt; myVector.size(); ++i)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; myVector[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i + 1 &lt; myVector.size())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; ' ';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
&nbsp;  cout &lt;&lt; endl;<br />
}<br />
<br />
/******************************************************************************<br />
* heapsort<br />
* Desc: Performs a heapsort on a given vector, with O(n log n).<br />
* Input: Vector to be sorted<br />
******************************************************************************/<br />
void heapsort(vector &lt; int &gt; &amp;myVector)<br />
{<br />
&nbsp;  heapify(myVector, myVector.size());<br />
&nbsp;  int wall = myVector.size() - 1;<br />
&nbsp;  int temp; //used for swapping values<br />
&nbsp;  while (wall &gt; 0)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = myVector[wall];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myVector[wall] = myVector[0];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myVector[0] = temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; percolateDown(myVector, 0, wall);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --wall;<br />
&nbsp;  }<br />
}</pre><br />
Input and expected/actual output:<br />
<br />
Test 1:<br />
<br />
Input:<br />
45 22 35 21 9 40 31 39 3 39 23 29 16 49 16 22 20 7 35 7 31 47 1 12 10 41 14 15 13 31 42 8 3 26 28 11 15 9 49 18 47 22 46 12 20 11 33 40 18 18 47 48 15 47 10 24 38 23 39 1 4 30 8 6 5 36 16 20 44 15 38 40 36 33 2 6 44 35 46 11 3 42 9 18 39 19 41 27 41 30 27 44 10 35 49 15 20 15 35 13<br />
<br />
Expected:<br />
1 1 2 3 3 3 4 5 6 6 7 7 8 8 9 9 9 10 10 10 11 11 11 12 12 13 13 14 15 15 15 15 15 15 16 16 16 18 18 18 18 19 20 20 20 20 21 22 22 22 23 23 24 26 27 27 28 29 30 30 31 31 31 33 33 35 35 35 35 35 36 36 38 38 39 39 39 39 40 40 40 41 41 41 42 42 44 44 44 45 46 46 47 47 47 47 48 49 49 49<br />
<br />
Actual:<br />
7 2 1 9 23 5 3 1 8 6 8 9 3 10 10 11 7 11 11 12 12 15 13 13 14 15 15 9 15 6 15 15 31 16 16 16 4 18 18 18 19 20 20 20 20 21 22 22 22 23 10 24 26 27 27 28 29 30 30 31 31 3 33 33 35 49 35 35 35 35 36 36 38 38 39 39 39 39 40 40 40 41 41 41 42 42 44 44 44 45 46 46 47 47 47 47 48 49 18 49<br />
<br />
Test 2:<br />
<br />
Input:<br />
35 26 10 1 17 21 47 13 5 10 26 20 41 12 39 37 41 49 9 23 25 24 27 30 18 37 17 40 37 35 47 21 10 7 21 27 27 18 39 31 27 15 50 18 26 38 5 16 37 13 39 11 37 16 41 4 2 7 44 38 42 40 9 1 46 30 28 22 47 17 3 24 31 2 41 7 40 45 23 26 8 11 36 45 27 26 48 28 33 41 15 24 31 23 25 26 2 2 48 49<br />
<br />
Expected:<br />
1 1 2 2 2 2 3 4 5 5 7 7 7 8 9 9 10 10 10 11 11 12 13 13 15 15 16 16 17 17 17 18 18 18 20 21 21 21 22 23 23 23 24 24 24 25 25 26 26 26 26 26 26 27 27 27 27 27 28 28 30 30 31 31 31 33 35 35 36 37 37 37 37 37 38 38 39 39 39 40 40 40 41 41 41 41 41 42 44 45 45 46 47 47 47 48 48 49 49 50<br />
<br />
Actual:<br />
10 2 2 5 7 4 2 1 7 5 2 7 9 9 10 3 10 11 11 12 13 13 17 15 15 16 21 16 17 8 17 18 18 18 20 21 21 1 22 23 23 23 24 24 25 25 26 26 26 26 26 26 27 27 27 27 27 28 28 30 30 46 31 31 31 33 35 35 36 37 37 37 37 37 38 38 39 39 39 40 40 40 41 41 41 41 41 42 44 45 45 24 47 47 47 48 48 49 49 50</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>wmsigler</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241420.html</guid>
		</item>
		<item>
			<title>Finding the Largest</title>
			<link>http://www.daniweb.com/forums/thread241414.html</link>
			<pubDate>Thu, 26 Nov 2009 01:24:27 GMT</pubDate>
			<description>How do I make an array to find the largest portion of another array? 
 
I am trying to find the candidate that received the largest amount of votes from the following file: 
 
Johnson  5000		 
Miller   4000		 
Duffy    6000	 
Robinson 2500	 
Ashtony  1800</description>
			<content:encoded><![CDATA[<div>How do I make an array to find the largest portion of another array?<br />
<br />
I am trying to find the candidate that received the largest amount of votes from the following file:<br />
<br />
Johnson  5000		<br />
Miller   4000		<br />
Duffy    6000	<br />
Robinson 2500	<br />
Ashtony  1800		<br />
<br />
here is my code:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;fstream&gt;<br />
using namespace std;<br />
<br />
<br />
int main()<br />
{<br />
&nbsp;  string candidates[6];<br />
&nbsp;  double votes[6];<br />
&nbsp;  double sum = 0.0;<br />
<br />
&nbsp;  ifstream inFile(&quot;candidates.txt&quot;);<br />
<br />
&nbsp;  for ( int i = 0; i &lt; 6; ++i )<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; if ( inFile &gt;&gt; candidates[i] &gt;&gt; votes[i] )<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum = sum + votes[i];<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
&nbsp;  cout &lt;&lt; endl;<br />
&nbsp;  <br />
&nbsp;  cout &lt;&lt; &quot;Candidate&nbsp; &nbsp; &nbsp; Votes&nbsp; &nbsp; &nbsp; % of Total&quot; &lt;&lt; endl;<br />
<br />
&nbsp;  cout &lt;&lt; setprecision(0) &lt;&lt; candidates[0] &lt;&lt; setw(5) &lt;&lt; &quot;\t&quot; &lt;&lt; votes[0]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw(15) &lt;&lt; setprecision(4) &lt;&lt; ((votes[0] / sum) * 100) &lt;&lt; endl;<br />
&nbsp;  cout &lt;&lt; setprecision(0) &lt;&lt; candidates[1] &lt;&lt; setw(5) &lt;&lt; &quot;\t&quot; &lt;&lt; votes[1]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw(15) &lt;&lt; setprecision(4)&lt;&lt; ((votes[1] / sum) * 100) &lt;&lt; endl;<br />
&nbsp;  cout &lt;&lt; setprecision(0) &lt;&lt; candidates[2] &lt;&lt; setw(5) &lt;&lt; &quot;\t&quot; &lt;&lt; votes[2]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw(15) &lt;&lt; setprecision(4)&lt;&lt; ((votes[2] / sum) * 100) &lt;&lt; endl;<br />
&nbsp;  cout &lt;&lt; setprecision(0) &lt;&lt; candidates[3] &lt;&lt; setw(5) &lt;&lt; &quot;\t&quot; &lt;&lt; votes[3]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw(15) &lt;&lt; setprecision(4)&lt;&lt; ((votes[3] / sum) * 100) &lt;&lt; endl;<br />
&nbsp;  cout &lt;&lt; setprecision(0) &lt;&lt; candidates[4] &lt;&lt; setw(5) &lt;&lt; &quot;\t&quot; &lt;&lt; votes[4]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw(15) &lt;&lt; setprecision(3) &lt;&lt; ((votes[4] / sum) * 100) &lt;&lt; endl;<br />
<br />
&nbsp; <br />
&nbsp;  cout &lt;&lt; &quot;\n&quot; &lt;&lt; endl;<br />
&nbsp;  cout &lt;&lt; setprecision(0) &lt;&lt; &quot;Total &quot; &lt;&lt; setw(5) &lt;&lt; &quot;\t&quot; &lt;&lt; sum <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;\n&quot; &lt;&lt; endl;<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>PDB1982</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241414.html</guid>
		</item>
		<item>
			<title>Dynamic array insainty</title>
			<link>http://www.daniweb.com/forums/thread241408.html</link>
			<pubDate>Thu, 26 Nov 2009 00:21:25 GMT</pubDate>
			<description>Hello, i really need help on this. I fully cannot understand what i am doing wrong here. This is a segment of my project that uses dynamic arrays but i seem to be getting random memory related crashes that i cannot seem to fix. 
 
These are my encode/decode classes. 
 
They work by XORing every...</description>
			<content:encoded><![CDATA[<div>Hello, i really need help on this. I fully cannot understand what i am doing wrong here. This is a segment of my project that uses dynamic arrays but i seem to be getting random memory related crashes that i cannot seem to fix.<br />
<br />
These are my encode/decode classes.<br />
<br />
They work by XORing every char past the 3nd position by the diffrence between the 1st position XOR 4 and the 2nd postion XOR 6. <br />
<br />
My encode class works perfectly, its just my decode class, whenever the array for it to decode is more than 8 numbers it crashes, when it is less it works.<br />
<br />
I really cant work this out.. where am i going wrong?<br />
<br />
(The code is abit messy through frustration of debugging)<br />
<br />
#include &lt;windows.h&gt;<br />
#include &lt;iostream.h&gt;<br />
<br />
using namespace std;<br />
<br />
int debug = 1;<br />
<br />
char * Dec(int * Data, int stringlen){<br />
    <br />
    char * DecData = new char (stringlen+1);<br />
    <br />
    cout &lt;&lt; &quot;Dec---------------------------\n&quot;;    <br />
    <br />
    int a = (Data[0] ^ 4) ^ 45;<br />
    int b = (Data[1] ^ 6) ^ 17;<br />
    <br />
    int RecXor = b - a;<br />
    <br />
    cout &lt;&lt; &quot;XorKey = &quot; &lt;&lt; RecXor &lt;&lt; endl;<br />
<br />
    DecData[0] = Data[0] ^ 4;<br />
    DecData[1] = Data[1] ^ 6;<br />
    <br />
    cout &lt;&lt; &quot;0 &quot; &lt;&lt; (char)DecData[0] &lt;&lt; endl; <br />
    cout &lt;&lt; &quot;1 &quot; &lt;&lt; (char)DecData[1] &lt;&lt; endl; <br />
<br />
    for(int i = 2;i &lt; stringlen; i++){<br />
            if(debug)<br />
                     cout &lt;&lt; i &lt;&lt; &quot; &quot; &lt;&lt; (char)(Data[i] ^ RecXor) &lt;&lt; endl;<br />
            DecData[i] = Data[i] ^ RecXor;  <br />
            cout &lt;&lt; stringlen-i &lt;&lt; endl;<br />
    }<br />
    delete [] Data;<br />
    <br />
    DecData[stringlen] = '\0';<br />
    <br />
    cout &lt;&lt; DecData &lt;&lt; endl;<br />
    <br />
    return DecData;<br />
}<br />
<br />
int * Enc(char * Data){<br />
    <br />
    cout &lt;&lt; &quot;Enc---------------------------\n&quot;;<br />
<br />
    if(strlen(Data) &lt; 3){<br />
                    if(debug)<br />
                             cout &lt;&lt; &quot;Data is too short to encode\n&quot;;<br />
                    <br />
                    return 0;<br />
    }<br />
    <br />
    int * NewData = new int (strlen(Data));<br />
<br />
    NewData[0] = Data[0] ^ 4;<br />
    NewData[1] = Data[1] ^ 6;<br />
    <br />
    int XorKey = (Data[1] ^ 17) - (Data[0] ^ 45);<br />
    <br />
    cout &lt;&lt; &quot;XorKey = &quot; &lt;&lt; XorKey &lt;&lt; endl;<br />
<br />
    cout &lt;&lt; &quot;0 &quot; &lt;&lt; NewData[0] &lt;&lt; endl;<br />
    cout &lt;&lt; &quot;1 &quot; &lt;&lt; NewData[1] &lt;&lt; endl;<br />
<br />
    for(int i = 2; i &lt; strlen(Data);i++){<br />
            NewData[i] = (Data[i] ^ XorKey);<br />
            if(debug)<br />
                     cout &lt;&lt; i &lt;&lt; &quot; &quot; &lt;&lt; NewData[i] &lt;&lt; endl;<br />
    }<br />
    <br />
    delete [] Data;<br />
    <br />
    return NewData;<br />
}<br />
<br />
int main(){<br />
<br />
    int * encode = Enc(&quot;AAAAAAAA&quot;);<br />
    char * decode = Dec(encode, 8);<br />
    system(&quot;pause&quot;);<br />
    <br />
    return 0;<br />
}<br />
<br />
Thanks in advance for any help</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Jamesinuk</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241408.html</guid>
		</item>
		<item>
			<title>A matrix with just one for loop</title>
			<link>http://www.daniweb.com/forums/thread241403.html</link>
			<pubDate>Wed, 25 Nov 2009 23:39:23 GMT</pubDate>
			<description><![CDATA[Dear all, is there is a way to go trough a matrix using just one "for" loop?, I mean I have this snippet:  
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox"...]]></description>
			<content:encoded><![CDATA[<div>Dear all, is there is a way to go trough a matrix using just one &quot;for&quot; loop?, I mean I have this snippet: <br />
<br />
 <pre style="margin:20px; line-height:13px">#define WIDTH 5<br />
#define HEIGHT 3<br />
<br />
int mat [HEIGHT * WIDTH];<br />
int n,m;<br />
<br />
int main ()<br />
{<br />
&nbsp; for (n=0;n&lt;HEIGHT;n++)<br />
&nbsp; &nbsp; for (m=0;m&lt;WIDTH;m++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; mat[n*WIDTH+m]=(n+1)*(m+1);<br />
&nbsp; &nbsp; }<br />
&nbsp; return 0;<br />
}</pre><br />
But I was wondering if it is possible to go trough that pseudo-multidimensional array with one &quot;for&quot; loop. Actually I think that if the matrix is a square matrix may be is possible. Is it possible to <br />
<br />
Any help would be appreciated, Thank you very much in advanced.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>fjrivash</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241403.html</guid>
		</item>
		<item>
			<title>Trying to calculate scores but it crashes</title>
			<link>http://www.daniweb.com/forums/thread241401.html</link>
			<pubDate>Wed, 25 Nov 2009 23:27:27 GMT</pubDate>
			<description>Hi I manage to create some code to where it will read in a set of exam scores and display their category as well as if they enter an invalid number it repeats the code until the data is valid or until they enter the SENTINEL value but when I do it crashes after reading in 1 number and it does not...</description>
			<content:encoded><![CDATA[<div>Hi I manage to create some code to where it will read in a set of exam scores and display their category as well as if they enter an invalid number it repeats the code until the data is valid or until they enter the SENTINEL value but when I do it crashes after reading in 1 number and it does not repeat the loop if they enter in a invalid number.<br />
 <pre style="margin:20px; line-height:13px">const int SENTINEL = -999;<br />
<br />
int getData(int score, string category);<br />
string getCategory (int score, int amount, int &amp; numOutstanding, int &amp; numSatisfactory, int &amp; numUnsatisfactory);<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; int score = 0;<br />
&nbsp; &nbsp; int score2;<br />
&nbsp; &nbsp; int amount = 0;<br />
&nbsp; &nbsp; int numOutstanding = 0, numSatisfactory = 0, numUnsatisfactory = 0;<br />
&nbsp; &nbsp; string category;<br />
&nbsp; &nbsp; category = getCategory (score, amount, numOutstanding, numSatisfactory, numUnsatisfactory);<br />
&nbsp; &nbsp; score2 = getData(score, category);<br />
&nbsp; &nbsp; cout &lt;&lt; score2 &lt;&lt; endl;<br />
&nbsp; &nbsp; return 0;<br />
}<br />
int getData(int score, string category)<br />
{<br />
&nbsp; &nbsp; do<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter in exam scores from 0-100, -999 stops the program!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; score;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Your score is &quot; &lt;&lt; score &lt;&lt; &quot;Category: &quot; &lt;&lt; category &lt;&lt; endl;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; while(score &lt; 0 || score &gt; 100 &amp;&amp; score &lt; -999 || score &gt; -999);<br />
&nbsp; &nbsp; return 0;<br />
}<br />
string getCategory (int score, int amount, int &amp; numOutstanding, int &amp; numSatisfactory, int &amp; numUnsatisfactory)<br />
{<br />
&nbsp; &nbsp; if(score &gt;= 90 &amp;&amp; score &lt;= 100)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Outstanding!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; numOutstanding++;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; else if(score &gt;= 60 &amp;&amp; score &lt;= 89)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Satisfactory!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; numSatisfactory++;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; else if(score &gt;= 0 &amp;&amp; score &lt;= 59)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unsatisfactory!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; numUnsatisfactory++;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; amount++;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;The number of Outstanding scores is: &quot; &lt;&lt; numOutstanding &lt;&lt; &quot;.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;The number of Statisfactory scores is: &quot; &lt;&lt; numSatisfactory &lt;&lt; &quot;.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;The number of Unsatisfactory scores is: &quot; &lt;&lt; numUnsatisfactory &lt;&lt; &quot;.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;The total amount of scores entered is: &quot; &lt;&lt; amount &lt;&lt; &quot;.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>astroshark</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241401.html</guid>
		</item>
		<item>
			<title>bisection - finding the interval a root is in?</title>
			<link>http://www.daniweb.com/forums/thread241400.html</link>
			<pubDate>Wed, 25 Nov 2009 23:22:52 GMT</pubDate>
			<description>Hi all, 
 
For have implemented a program that performs the bisection method, currently with the user entering the initial interval to find one root. However I was wondering if I could get the program to find the intervals automatically without the users input. 
 
The only way I can think to do...</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
For have implemented a program that performs the bisection method, currently with the user entering the initial interval to find one root. However I was wondering if I could get the program to find the intervals automatically without the users input.<br />
<br />
The only way I can think to do this is by using the intermediate value theorem, and calculating the function values over a certain range.<br />
<br />
E.g for x^2 - 9 = 0<br />
<br />
f(-4) = 7<br />
f(-3) = 0<br />
f(-2) = -5<br />
f(-1) = -8<br />
f(0) = -9<br />
<br />
so we know there is a root when the sign changes etc. so obviously I can tell this from looking, but I'm struggling for a way of how to get c++ to recognise this? Could anyone please give me a push in the right direction?<br />
<br />
Thanks in advance!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>sexyzebra19</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241400.html</guid>
		</item>
		<item>
			<title>class issue</title>
			<link>http://www.daniweb.com/forums/thread241394.html</link>
			<pubDate>Wed, 25 Nov 2009 22:24:04 GMT</pubDate>
			<description><![CDATA[why is only my first class working? when i run this it just asks about the viruses and not the cost of the OS. 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox"...]]></description>
			<content:encoded><![CDATA[<div>why is only my first class working? when i run this it just asks about the viruses and not the cost of the OS.<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;<br />
<br />
<br />
class OperatingSystem<br />
{<br />
private:<br />
float cost;<br />
public:<br />
OperatingSystem() : cost(0) {}<br />
float getCost() { return cost; }<br />
void setCost(float cost) { OperatingSystem::cost = cost; }<br />
void inputInfo();<br />
void outputInfo();<br />
};<br />
<br />
class Windows : public OperatingSystem<br />
{<br />
private:<br />
unsigned long numberofviruses;<br />
public:<br />
Windows() : OperatingSystem(), numberofviruses(0) {}<br />
unsigned long getNumberofviruses() { return numberofviruses; }<br />
void setNumberofviruses(unsigned long numberofviruses)<br />
{ Windows::numberofviruses = numberofviruses; }<br />
void inputInfo();<br />
void outputInfo();<br />
};<br />
<br />
int main()<br />
{<br />
Windows variable1;<br />
<br />
variable1.inputInfo();<br />
variable1.outputInfo();<br />
<br />
return(0);<br />
}<br />
<br />
void Windows::inputInfo()<br />
{<br />
unsigned long temp;<br />
cout &lt;&lt; &quot;Enter the number of viruses Windows currently has: &quot;;<br />
cin &gt;&gt; temp;<br />
setNumberofviruses(temp);<br />
}<br />
<br />
void Windows::outputInfo()<br />
{<br />
cout &lt;&lt; &quot;Windows current has &quot; &lt;&lt; getNumberofviruses()<br />
&lt;&lt; &quot; known viruses.&quot; &lt;&lt; endl;<br />
}<br />
<br />
void OperatingSystem::inputInfo()<br />
{<br />
float temp;<br />
cout &lt;&lt; &quot;Enter the cost of the Operating System: &quot;;<br />
cin &gt;&gt; temp;<br />
setCost(temp);<br />
}<br />
<br />
void OperatingSystem::outputInfo()<br />
{<br />
cout &lt;&lt; &quot;Your Operating System cost $&quot; &lt;&lt; getCost() &lt;&lt; endl;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>itzaaron</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241394.html</guid>
		</item>
		<item>
			<title>Need help understanding a given constructor definition for an assignment.</title>
			<link>http://www.daniweb.com/forums/thread241392.html</link>
			<pubDate>Wed, 25 Nov 2009 22:10:14 GMT</pubDate>
			<description><![CDATA[We are working on a header file for a template class called TreeNode.  My class definition is as follows: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox"...]]></description>
			<content:encoded><![CDATA[<div>We are working on a header file for a template class called TreeNode.  My class definition is as follows:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
<br />
template &lt;class T&gt; class BSTree;<br />
class TreeNode&lt;T&gt;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; friend classBSTree&lt;T&gt;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //constructor<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TreeNode( T = T(), TreeNode&lt;T&gt;* = 0, TreeNode&lt;T&gt;* = 0 );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; T data;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //holds data of interest<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TreeNode&lt;T&gt; *linkL;&nbsp; &nbsp; &nbsp; &nbsp; //pointer to left link<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TreeNode&lt;T&gt; *linkR;&nbsp; //pointer to right link<br />
&nbsp; &nbsp; &nbsp; &nbsp; };//end TreeNode</pre><br />
I am unclear on what the argument T = T() means.  It was given by the instructor.  I understand that it is an argument of type T being initialized.  But, don't get what it means to initialize to T()?  This leads me to the problem of writing the implementation portion of the header.  <br />
<br />
This is what I want to write for the function header for the constructor:<br />
<br />
 <pre style="margin:20px; line-height:13px">TreeNode&lt;T&gt;::TreeNode(T d, TreeNode&lt;T&gt; right, TreeNode&lt;T&gt; left)<br />
{<br />
data = d;<br />
linkR = right;<br />
linkL = left;<br />
}</pre><br />
I am really not looking for any code per se.  But, would really appreciate a thorough explanation geared toward a novice programmer.<br />
<br />
Thanks in Advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>big_guy_bri</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241392.html</guid>
		</item>
		<item>
			<title>Candidate Votes</title>
			<link>http://www.daniweb.com/forums/thread241385.html</link>
			<pubDate>Wed, 25 Nov 2009 21:10:20 GMT</pubDate>
			<description><![CDATA[I'm working on a program where I need to input a file with 5 candidates names and votes, and output the name, votes, and the percentage of total votes that candidate received, as well as the overall winner.  Right now I've been able to create some arrays and output the basic information, but I have...]]></description>
			<content:encoded><![CDATA[<div>I'm working on a program where I need to input a file with 5 candidates names and votes, and output the name, votes, and the percentage of total votes that candidate received, as well as the overall winner.  Right now I've been able to create some arrays and output the basic information, but I have two problems:<br />
<br />
1).  My output is showing<br />
<br />
 -858993460<br />
Johnson 5000<br />
Miller 4000<br />
Duffy 6000<br />
Robinson 2500<br />
Ashtony 1800<br />
Press any key to continue . . .<br />
<br />
But, I don't know where the -858993460 is coming from...!?!<br />
<br />
2).  Where should I go from here?<br />
<br />
<br />
<br />
<br />
Here is my code:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;string&gt;<br />
#include &lt;fstream&gt;<br />
using namespace std;<br />
<br />
void main()<br />
{<br />
&nbsp; &nbsp; int numCan = 0;<br />
&nbsp; &nbsp; string candidates[10];<br />
&nbsp; &nbsp; int votes[10];<br />
<br />
&nbsp; &nbsp; ifstream inFile;<br />
&nbsp;  <br />
&nbsp; &nbsp; inFile.open(&quot;candidates.txt&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(inFile &amp;&amp; numCan &lt; 10)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; candidates[numCan] &lt;&lt; &quot; &quot; &lt;&lt; votes[numCan] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numCan++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inFile &gt;&gt; candidates[numCan] &gt;&gt; votes[numCan];&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; inFile &gt;&gt; candidates[numCan] &gt;&gt; votes[numCan];<br />
<br />
&nbsp; &nbsp; inFile.close();<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>PDB1982</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241385.html</guid>
		</item>
		<item>
			<title>do a command line switch with an if statement</title>
			<link>http://www.daniweb.com/forums/thread241376.html</link>
			<pubDate>Wed, 25 Nov 2009 20:31:21 GMT</pubDate>
			<description><![CDATA[I am trying to do a command line switch with an if statement. The problem I am running into is when I am using a letter, it wont recognize it. When I use a number, no problem. I think there are a few different ways to solve this. Can anyone show me the most direct way? 
 
Thanks.  
 
  <div...]]></description>
			<content:encoded><![CDATA[<div>I am trying to do a command line switch with an if statement. The problem I am running into is when I am using a letter, it wont recognize it. When I use a number, no problem. I think there are a few different ways to solve this. Can anyone show me the most direct way?<br />
<br />
Thanks. <br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
<br />
#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
<br />
int main ( int argc, char *argv[] )<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (argv[1] == &quot;-d&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;yes, it works&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;no, it won't read the if statement&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>T-Dogg3030</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241376.html</guid>
		</item>
		<item>
			<title>Linked List Functionality Problem</title>
			<link>http://www.daniweb.com/forums/thread241360.html</link>
			<pubDate>Wed, 25 Nov 2009 18:40:41 GMT</pubDate>
			<description><![CDATA[Hi, I have created a generic linked list in which different objects can be added to a list as long as they inherit from my object class. My problem is this: 
I am able to add nodes and find nodes etc. but I can't figure out how to return an instance of an Object which has been added. 
Below shows...]]></description>
			<content:encoded><![CDATA[<div>Hi, I have created a generic linked list in which different objects can be added to a list as long as they inherit from my object class. My problem is this:<br />
I am able to add nodes and find nodes etc. but I can't figure out how to return an instance of an Object which has been added.<br />
Below shows the code I am having trouble with (although there are many different instances of this problem, they can hopefully be resolved through this one instance being solved):<br />
<br />
 <pre style="margin:20px; line-height:13px">int Bank::customerSearch(unsigned int custNum)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; theCustomers.size(); ++i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Customer c = theCustomers.at(i); //here is my problem<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(c.getCustNum() == custNum)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return -1;<br />
}</pre><br />
When I try to assign the customer instance my program breaks because in my list the at() function is currently returning an Object reference as opposed to a Customer reference. I need to somehow return a reference to a Customer (or Account or Mortgage) instead so that it works similar to the at() function in a vector.<br />
<br />
I have attached the header file and cpp file that I use for my linked list.<br />
<br />
Thanks</div>  <br /> <div style="padding:5px">     <fieldset class="fieldset"> <legend>Attached Files</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/cpp.gif" alt="File Type: cpp" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12708&amp;d=1259174400">myList.cpp</a> (2.2 KB)</td> </tr><tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/h.gif" alt="File Type: h" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12709&amp;d=1259174417">myList.h</a> (994 Bytes)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>caged_fire</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241360.html</guid>
		</item>
		<item>
			<title>adding elements in a dynamic array</title>
			<link>http://www.daniweb.com/forums/thread241341.html</link>
			<pubDate>Wed, 25 Nov 2009 17:14:18 GMT</pubDate>
			<description><![CDATA[Hi to all, I have a homework about a banking system. I try to adding a branch in an array and the size of array dynamically increased. Here is my code but it gives run time error. 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hi to all, I have a homework about a banking system. I try to adding a branch in an array and the size of array dynamically increased. Here is my code but it gives run time error.<br />
 <pre style="margin:20px; line-height:13px">#include &quot;BankingSystem.h&quot;<br />
#include &quot;Branch.h&quot;<br />
#include &lt;iostream&gt;<br />
using namespace std;<br />
BankingSystem::BankingSystem(){<br />
&nbsp; &nbsp; size=0;<br />
&nbsp; &nbsp; branches=NULL;<br />
}<br />
<br />
void BankingSystem:: addBranch( const int branchId, const string branchName ){<br />
&nbsp; &nbsp; Branch b= Branch(branchId, branchName);<br />
&nbsp; &nbsp; if(size==0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; size++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; branches=new Branch[size];<br />
&nbsp; &nbsp; &nbsp; &nbsp; branches[0]=b;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Branch &quot;&lt;&lt; b.getBranchId()&lt;&lt; &quot; has been added.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0;i&lt;size;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(branches[i].getBranchId()==b.getBranchId()){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Branch &quot;&lt;&lt;b.getBranchId()&lt;&lt;&quot; already exists.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; int newsize= size++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Branch *temp=new Branch[newsize];<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0;i&lt;size;i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp[i]=branches[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; temp[size]=b;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Branch &quot;&lt;&lt; b.getBranchId()&lt;&lt; &quot; has been added.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; delete[] branches;<br />
&nbsp; &nbsp; &nbsp; &nbsp; branches=temp;<br />
<br />
&nbsp; &nbsp; }<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>jacline</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241341.html</guid>
		</item>
		<item>
			<title>Global Class in DLL</title>
			<link>http://www.daniweb.com/forums/thread241337.html</link>
			<pubDate>Wed, 25 Nov 2009 17:00:39 GMT</pubDate>
			<description><![CDATA[Hello all :) 
 
I'm working on a DLL with various of functions I later need in other applications. I have many classes, and most of them I need a global instance of. I've tried various things such as a singletonptr, singleton, global instantiation. 
 
What I need to achieve is the ability to use...]]></description>
			<content:encoded><![CDATA[<div>Hello all :)<br />
<br />
I'm working on a DLL with various of functions I later need in other applications. I have many classes, and most of them I need a global instance of. I've tried various things such as a singletonptr, singleton, global instantiation.<br />
<br />
What I need to achieve is the ability to use the same instance of a class from the client application, but also in the DLL.<br />
<br />
An example of what I want to be able to:<br />
<br />
DLL_Log:<br />
 <pre style="margin:20px; line-height:13px">void createLog(){ create_txt_file(); and_save_pointer(); }<br />
void writeToLog(message){ open_txt_file(with_saved_pointer()); }</pre><br />
DLL_Math:<br />
 <pre style="margin:20px; line-height:13px">void AplusB(int a, int b){ log_class-&gt;writeToLog(a+b); }</pre><br />
EXE_Main:<br />
 <pre style="margin:20px; line-height:13px">log_class-&gt;createLog();<br />
log_class-&gt;writeLog(&quot;application started!&quot;);<br />
math_class-&gt;AplusB(5, 20);</pre><br />
Now the log file should be something like &quot;Application started&quot; &quot;25&quot;.<br />
<br />
In what I have made, I would get two different log classes, one in the DLL and one in the EXE.<br />
<br />
<span style="font-weight:bold">What ways are there to do this?</span><br />
Sorry for the poor sample code, but I didn't have anything small I could copy over.<br />
<br />
Thanks<br />
- Excizted :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Excizted</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241337.html</guid>
		</item>
		<item>
			<title>Returning istream from a function</title>
			<link>http://www.daniweb.com/forums/thread241335.html</link>
			<pubDate>Wed, 25 Nov 2009 16:58:27 GMT</pubDate>
			<description><![CDATA[Hey guys...Can you please help me explain what does returning an istream object mean. 
 
I am currently studying Accelerated C++ and at many places a function returns istream object. What does it mean? 
 
For example:- 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>Hey guys...Can you please help me explain what does returning an istream object mean.<br />
<br />
I am currently studying Accelerated C++ and at many places a function returns istream object. What does it mean?<br />
<br />
For example:-<br />
 <pre style="margin:20px; line-height:13px">istream&amp; read(istream&amp; is, Student_info&amp; s)<br />
{<br />
// read and store the student's name and midterm and final exam grades<br />
is &gt;&gt; s.name &gt;&gt; s.midterm &gt;&gt; s.final;<br />
read_hw(is, s.homework); // read and store all the student's homework grades<br />
return is;<br />
}</pre><br />
 <pre style="margin:20px; line-height:13px">istream&amp; read_hw(istream&amp; in, vector&lt;double&gt;&amp; hw)<br />
{<br />
if (in) {<br />
// get rid of previous contents<br />
hw.clear() ;<br />
// read homework grades<br />
double x;<br />
while (in &gt;&gt; x)<br />
hw.push_back(x);<br />
// clear the stream so that input will work for the next student<br />
in.clear();<br />
}<br />
return in;<br />
}</pre><br />
What do the two functions mean? Basically, I want to ask what does passing an istream object mean and returning an istream object do?<br />
<br />
And they are using &quot;is&quot; with &quot;&gt;&gt;&quot;. Isn't cin used there?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Nikhar</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread241335.html</guid>
		</item>
	</channel>
</rss>
