<?xml version="1.0" encoding="ISO-8859-1"?>

<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>CodeGuru Forums - C++  (Non Visual C++ Issues)</title>
		<link>http://forums.codeguru.com/</link>
		<description>Ask or answer C and C++ questions not related to Visual C++. This includes Console programming, Linux programming, or general ANSI C++.</description>
		<language>en</language>
		<lastBuildDate>Tue, 21 May 2013 04:20:33 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://forums.codeguru.com/images/misc/rss.png</url>
			<title>CodeGuru Forums - C++  (Non Visual C++ Issues)</title>
			<link>http://forums.codeguru.com/</link>
		</image>
		<item>
			<title>Looking for chars in string.</title>
			<link>http://forums.codeguru.com/showthread.php?537143-Looking-for-chars-in-string.&amp;goto=newpost</link>
			<pubDate>Mon, 20 May 2013 15:10:39 GMT</pubDate>
			<description><![CDATA[Hi gurus.

I'm looking for a algorithm to search portions of string that have the same caracter. The only possible values are: a,n and g

Char index:  0 1 2 3 4 5 6 7 8 9       RESULT
------------------------------------------
Example 1:  a g g g a a                  0,4
Example 2:  g g g a n n a               0,3
Example 3:  a g g g g g g a             0,7
Example 4:  g g g g g g g               0,6
Example 5:  g g a a g a a a g          0,2,3,5,7,8


Thanks in advance, I'm collapsed :o

Best regards]]></description>
			<content:encoded><![CDATA[<div>Hi gurus.<br />
<br />
I'm looking for a algorithm to search portions of string that have the same caracter. The only possible values are: a,n and g<br />
<br />
Char index:  0 1 2 3 4 5 6 7 8 9       RESULT<br />
------------------------------------------<br />
Example 1:  a g g g a a                  0,4<br />
Example 2:  g g g a n n a               0,3<br />
Example 3:  a g g g g g g a             0,7<br />
Example 4:  g g g g g g g               0,6<br />
Example 5:  g g a a g a a a g          0,2,3,5,7,8<br />
<br />
<br />
Thanks in advance, I'm collapsed :o<br />
<br />
Best regards</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>juanpast</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537143-Looking-for-chars-in-string.</guid>
		</item>
		<item>
			<title>Problem in Algorithm Recursive?</title>
			<link>http://forums.codeguru.com/showthread.php?537131-Problem-in-Algorithm-Recursive&amp;goto=newpost</link>
			<pubDate>Sun, 19 May 2013 23:35:44 GMT</pubDate>
			<description><![CDATA[Hello friends, I have a problem to implement a recursive version of an algorithm that I made, I get different values, I hope you can help me, here are the code so Iterative (OK) and Recursive code form that is not OK.

The data sets do not give equal:

The algorithm is given two source and target positions on a board, find the number of paths between them...

Input Example: 5
2 3
4 4
Output Example:

5



I hope its not help that I'm wrong!!!

Iterative Algorithm ( OK ) 

Code:
---------
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>

using namespace std;
int n , dp [1000][1000], x, y, xx, yy;
bool mark [1000][1000];

struct Punto
{
    int x;
    int y;
};

Punto inicio, fin , aux;
queue < Punto > lista;
int direcciones[3][2] = { {0,1}, {1,0}, {1,1} }; 

void BFS()
{
    lista.push(inicio);
    dp[ inicio.x ][ inicio.y ] = 1;
    while( !lista.empty() )
    {
        aux = lista.front();
        lista.pop();
        x = aux.x;
        y = aux.y;
        for(int i=0 ; i<3 ; i++) 
        {
            xx = direcciones[i][0]+x;
            yy = direcciones[i][1]+y;
            if( xx>0 && xx <= n && yy > 0 && yy <= n ) 
            {
                dp[xx][yy] += dp[x][y]; 
                if(!mark[xx][yy])
                {
                    mark[xx][yy] = true;
                    aux.x = xx;
                    aux.y = yy;
                    lista.push( aux );
                }
            }
        }
    }
}

int main()
{    
    cin>>n;
    cin>>x>>y;
    inicio.x = x;
    inicio.y = y;
    cin>>x>>y;
    fin.x = x;
    fin.y = y;
    BFS(); 
    cout<< dp[fin.x][fin.y] <<endl;
    system("pause");
    return 0;
}
---------
Recursive Algorithm ( not OK )

Code:
---------
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int n , dp [1000][1000], x, y, xx, yy;
bool mark [1000][1000];

struct Punto
{
    int x;
    int y;
};

Punto inicio, fin , aux;
queue < Punto > lista;
int direcciones[3][2] = { {0,1}, {1,0}, {1,1} }; 

void BFS(Punto aux){
	x=aux.x;
	y=aux.y;
	for(int i=0;i<3;i++){
		xx=direcciones[i][0]+x;
		yy=direcciones[i][1]+y;
		if( xx>0 && xx <= n && yy > 0 && yy <= n )
		{
			dp[xx][yy] += dp[x][y]; 
			if(!mark[xx][yy])
			{
				mark[xx][yy] = true; 
				aux.x = xx;
				aux.y = yy;
				BFS( aux );
			}
		}
	}
}

int main()
{
    cin>>n;
    cin>>x>>y;
    inicio.x = x;
    inicio.y = y;
    cin>>x>>y;
    fin.x = x;
    fin.y = y;
   
    dp[ inicio.x ][ inicio.y ] = 1;
    BFS(inicio);
  
    cout<< dp[fin.x][fin.y] <<endl; 
    system("pause");
    return 0;
}
---------
I hope its not help that I'm wrong!!!
cronos]]></description>
			<content:encoded><![CDATA[<div>Hello friends, I have a problem to implement a recursive version of an algorithm that I made, I get different values, I hope you can help me, here are the code so Iterative (OK) and Recursive code form that is not OK.<br />
<br />
The data sets do not give equal:<br />
<br />
The algorithm is given two source and target positions on a board, find the number of paths between them...<br />
<br />
Input Example: 5<br />
2 3<br />
4 4<br />
Output Example:<br />
<br />
5<br />
<br />
<br />
<br />
I hope its not help that I'm wrong!!!<br />
<br />
Iterative Algorithm ( OK ) <br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">#include &lt;iostream&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;cmath&gt;<br />
#include &lt;algorithm&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;queue&gt;<br />
<br />
using namespace std;<br />
int n , dp [1000][1000], x, y, xx, yy;<br />
bool mark [1000][1000];<br />
<br />
struct Punto<br />
{<br />
&nbsp; &nbsp; int x;<br />
&nbsp; &nbsp; int y;<br />
};<br />
<br />
Punto inicio, fin , aux;<br />
queue &lt; Punto &gt; lista;<br />
int direcciones[3][2] = { {0,1}, {1,0}, {1,1} }; <br />
<br />
void BFS()<br />
{<br />
&nbsp; &nbsp; lista.push(inicio);<br />
&nbsp; &nbsp; dp[ inicio.x ][ inicio.y ] = 1;<br />
&nbsp; &nbsp; while( !lista.empty() )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; aux = lista.front();<br />
&nbsp; &nbsp; &nbsp; &nbsp; lista.pop();<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = aux.x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; y = aux.y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0 ; i&lt;3 ; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xx = direcciones[i][0]+x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yy = direcciones[i][1]+y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( xx&gt;0 &amp;&amp; xx &lt;= n &amp;&amp; yy &gt; 0 &amp;&amp; yy &lt;= n ) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dp[xx][yy] += dp[x][y]; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!mark[xx][yy])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mark[xx][yy] = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aux.x = xx;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aux.y = yy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lista.push( aux );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
int main()<br />
{&nbsp; &nbsp; <br />
&nbsp; &nbsp; cin&gt;&gt;n;<br />
&nbsp; &nbsp; cin&gt;&gt;x&gt;&gt;y;<br />
&nbsp; &nbsp; inicio.x = x;<br />
&nbsp; &nbsp; inicio.y = y;<br />
&nbsp; &nbsp; cin&gt;&gt;x&gt;&gt;y;<br />
&nbsp; &nbsp; fin.x = x;<br />
&nbsp; &nbsp; fin.y = y;<br />
&nbsp; &nbsp; BFS(); <br />
&nbsp; &nbsp; cout&lt;&lt; dp[fin.x][fin.y] &lt;&lt;endl;<br />
&nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; return 0;<br />
}</code><hr />
</div> Recursive Algorithm ( not OK )<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">#include &lt;iostream&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;algorithm&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;cmath&gt;<br />
#include &lt;queue&gt;<br />
#include &lt;map&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;stack&gt;<br />
using namespace std;<br />
int n , dp [1000][1000], x, y, xx, yy;<br />
bool mark [1000][1000];<br />
<br />
struct Punto<br />
{<br />
&nbsp; &nbsp; int x;<br />
&nbsp; &nbsp; int y;<br />
};<br />
<br />
Punto inicio, fin , aux;<br />
queue &lt; Punto &gt; lista;<br />
int direcciones[3][2] = { {0,1}, {1,0}, {1,1} }; <br />
<br />
void BFS(Punto aux){<br />
&nbsp; &nbsp; &nbsp; &nbsp; x=aux.x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; y=aux.y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0;i&lt;3;i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xx=direcciones[i][0]+x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yy=direcciones[i][1]+y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( xx&gt;0 &amp;&amp; xx &lt;= n &amp;&amp; yy &gt; 0 &amp;&amp; yy &lt;= n )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dp[xx][yy] += dp[x][y]; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!mark[xx][yy])<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; mark[xx][yy] = true; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aux.x = xx;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aux.y = yy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BFS( aux );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; cin&gt;&gt;n;<br />
&nbsp; &nbsp; cin&gt;&gt;x&gt;&gt;y;<br />
&nbsp; &nbsp; inicio.x = x;<br />
&nbsp; &nbsp; inicio.y = y;<br />
&nbsp; &nbsp; cin&gt;&gt;x&gt;&gt;y;<br />
&nbsp; &nbsp; fin.x = x;<br />
&nbsp; &nbsp; fin.y = y;<br />
&nbsp;  <br />
&nbsp; &nbsp; dp[ inicio.x ][ inicio.y ] = 1;<br />
&nbsp; &nbsp; BFS(inicio);<br />
&nbsp; <br />
&nbsp; &nbsp; cout&lt;&lt; dp[fin.x][fin.y] &lt;&lt;endl; <br />
&nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; return 0;<br />
}</code><hr />
</div> I hope its not help that I'm wrong!!!<br />
cronos</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>carburo</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537131-Problem-in-Algorithm-Recursive</guid>
		</item>
		<item>
			<title>calling a script from a makefile</title>
			<link>http://forums.codeguru.com/showthread.php?537097-calling-a-script-from-a-makefile&amp;goto=newpost</link>
			<pubDate>Sat, 18 May 2013 22:38:46 GMT</pubDate>
			<description><![CDATA[Hello,

As advertized, I would like to call a script from a makfile to glean some information about the OS. What I more or less need is the OS name and version (CentOS-5.9, OPENSUSE-12.2, Cygwin, etc). I think I can get the rest of what I need from uname. The OS name and version doesn't seem to reside in any consistent place over the various Linux flavors. I also need to get the version of the gnu c compiler, since I think that may also require a bit more involved scripting than I would like to try out of make.

The main question is weather I can call a script out of make and have it return a value for a variable.

Something like,

OS   := $(shell ./script_name)

Thanks,

*LMHmedchem*]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
As advertized, I would like to call a script from a makfile to glean some information about the OS. What I more or less need is the OS name and version (CentOS-5.9, OPENSUSE-12.2, Cygwin, etc). I think I can get the rest of what I need from uname. The OS name and version doesn't seem to reside in any consistent place over the various Linux flavors. I also need to get the version of the gnu c compiler, since I think that may also require a bit more involved scripting than I would like to try out of make.<br />
<br />
The main question is weather I can call a script out of make and have it return a value for a variable.<br />
<br />
Something like,<br />
<br />
OS   := $(shell ./script_name)<br />
<br />
Thanks,<br />
<br />
<b>LMHmedchem</b></div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>LMHmedchem</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537097-calling-a-script-from-a-makefile</guid>
		</item>
		<item>
			<title>pls help, BHO (Browser Helper object) issue.</title>
			<link>http://forums.codeguru.com/showthread.php?537089-pls-help-BHO-(Browser-Helper-object)-issue.&amp;goto=newpost</link>
			<pubDate>Sat, 18 May 2013 14:55:42 GMT</pubDate>
			<description>Hi all,

I am totally new to developing BHO in c++, was thinking someone could give me a hand in source code or something to develop BHO (browser helper object). To inject html, javascript to a web browser

All help will be greatly appreciated.</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I am totally new to developing BHO in c++, was thinking someone could give me a hand in source code or something to develop BHO (browser helper object). To inject html, javascript to a web browser<br />
<br />
All help will be greatly appreciated.</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>mindjos</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537089-pls-help-BHO-(Browser-Helper-object)-issue.</guid>
		</item>
		<item>
			<title>Searching a vector of objects for pairs</title>
			<link>http://forums.codeguru.com/showthread.php?537047-Searching-a-vector-of-objects-for-pairs&amp;goto=newpost</link>
			<pubDate>Thu, 16 May 2013 18:35:56 GMT</pubDate>
			<description>Hello all,

Say I have a vector of objects and I want to return an object based on a pair of strings. The strings can be in either order Ie; A B==B A.

In general, what do you think is the best way to do this?

Thanks,
T.</description>
			<content:encoded><![CDATA[<div>Hello all,<br />
<br />
Say I have a vector of objects and I want to return an object based on a pair of strings. The strings can be in either order Ie; A B==B A.<br />
<br />
In general, what do you think is the best way to do this?<br />
<br />
Thanks,<br />
T.</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>azeotrope</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537047-Searching-a-vector-of-objects-for-pairs</guid>
		</item>
		<item>
			<title>Creating a Property (Get/Set) Class</title>
			<link>http://forums.codeguru.com/showthread.php?537037-Creating-a-Property-(Get-Set)-Class&amp;goto=newpost</link>
			<pubDate>Thu, 16 May 2013 12:47:35 GMT</pubDate>
			<description><![CDATA[Hi there,

I've just recently moved from Visual Basic 6 over to C++ and decided that I would try and write a class to mimic the Get/Set behavior seen in a variety of other programming languages. So instead of just using an overloaded function, i.e:
Code:
---------
class NoProp
{
    LPCWSTR m_Title;
public:
    void Title(LPCWSTR NewValue) {m_Title = NewValue;};
    LPCWSTR Title() {return m_Title;};
};

// ...

instNoProp->Title(L"New title!");  // Set

MessageBox(NULL, instNoProp->Title(), NULL, 0);  // Get
---------
I could just write the following:
Code:
---------
instProp->Title = L"New title!";  // Set

MessageBox(NULL, instProp->Title, NULL, 0);  // Get
---------
After about a week of playing around I came up with the following *Property* class, and another class named *InitProp* as a helper.
Code:
---------
#include <windows.h>

template <class tParent, class tProperty>class Property;

template <class tParent, class tProperty>
class InitProp
{
	typedef tProperty (tParent::*GET_PROP)(tParent*);
	typedef void (tParent::*SET_PROP)(tParent*, tProperty);

public:
	InitProp(tParent *cParent,
			 Property<tParent, tProperty> *cProperty,
			 tProperty *&tVariable,
			 GET_PROP Get_Property,
			 SET_PROP Set_Property)
	{
		cProperty->m_Property = new tProperty;
		*cProperty->m_Property = NULL;

		tVariable = cProperty->m_Property;

		cProperty->m_Parent = cParent;
		cProperty->m_Copy = 0;
		cProperty->m_Get_Property = Get_Property;
		cProperty->m_Set_Property = Set_Property;
	};
};

template <class tParent, class tProperty>
class Property
{
	typedef tProperty (tParent::*GET_PROP)(tParent*);
	typedef void (tParent::*SET_PROP)(tParent*, tProperty);

public:
	friend class InitProp<tParent, tProperty>;

	Property()
	{
		m_Parent = NULL;
		m_Set_Property = NULL;
		m_Get_Property = NULL;
	};

	~Property()
	{
		if (m_Copy-- == 0)
			delete m_Property;
	};

	Property operator= (tProperty NewValue)
	{
		if (m_Set_Property != NULL)
			(m_Parent->*m_Set_Property)(m_Parent, NewValue);
		
		return *this;
	}

	Property(const Property& Prop)
	{
		++m_Copy;
	};

	operator tProperty()
	{
		if (m_Get_Property != NULL)
			return (m_Parent->*m_Get_Property)(m_Parent);
		else
			return NULL;
	};

private:
	int m_Copy;
	tParent *m_Parent;
	tProperty *m_Property;
	GET_PROP m_Get_Property;
	SET_PROP m_Set_Property;
};

class Form
{
public:
	Property<Form, LPCWSTR> Title;

	Form()
	{
		InitProp<Form, LPCWSTR> pTitle(this, &Title, m_Title, &Form::g_Title, &Form::s_Title);
	};

private:
	LPCWSTR *m_Title;

	LPCWSTR g_Title(Form *Sender)
	{
		// User called Form.Title

		return *Sender->m_Title;
	};

	void s_Title(Form *Sender, LPCWSTR NewValue)
	{
		// User set Form.Title =

		*Sender->m_Title = NewValue;
	};

};

int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	Form *frmMain;
	frmMain = new Form;

	frmMain->Title = L"This is just a test!";

	MessageBox(NULL, frmMain->Title, NULL, 0);

	delete frmMain;

	return 0;
}
---------
So far this code only works with the LPCWSTR type (const wchar_t*). Unfortunately I got to this stage using only that type, and now when I try another type, such as int, it fails. When using the int type I believe it creates an error because the constructor of *InitProp* expects a type of pointer to be parsed. When I try using it with *int** type (the private variable then becoming int **m_Variable) it compiles, thought I cannot access the property like a normal *int*.

My best guess from here is that I probably have to overload the *InitProp* constructor in a way that it can setup the *Property* classes for base-types and pointer-types, and then also modify the *Property* class to handle both.

I'd appreciate any suggestions and input as I'm becoming lost in template->pointer-land.

Thanks!]]></description>
			<content:encoded><![CDATA[<div>Hi there,<br />
<br />
I've just recently moved from Visual Basic 6 over to C++ and decided that I would try and write a class to mimic the Get/Set behavior seen in a variety of other programming languages. So instead of just using an overloaded function, i.e:<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">class NoProp<br />
{<br />
&nbsp; &nbsp; LPCWSTR m_Title;<br />
public:<br />
&nbsp; &nbsp; void Title(LPCWSTR NewValue) {m_Title = NewValue;};<br />
&nbsp; &nbsp; LPCWSTR Title() {return m_Title;};<br />
};<br />
<br />
// ...<br />
<br />
instNoProp-&gt;Title(L&quot;New title!&quot;);&nbsp; // Set<br />
<br />
MessageBox(NULL, instNoProp-&gt;Title(), NULL, 0);&nbsp; // Get</code><hr />
</div> I could just write the following:<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">instProp-&gt;Title = L&quot;New title!&quot;;&nbsp; // Set<br />
<br />
MessageBox(NULL, instProp-&gt;Title, NULL, 0);&nbsp; // Get</code><hr />
</div> After about a week of playing around I came up with the following <b>Property</b> class, and another class named <b>InitProp</b> as a helper.<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">#include &lt;windows.h&gt;<br />
<br />
template &lt;class tParent, class tProperty&gt;class Property;<br />
<br />
template &lt;class tParent, class tProperty&gt;<br />
class InitProp<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; typedef tProperty (tParent::*GET_PROP)(tParent*);<br />
&nbsp; &nbsp; &nbsp; &nbsp; typedef void (tParent::*SET_PROP)(tParent*, tProperty);<br />
<br />
public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; InitProp(tParent *cParent,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Property&lt;tParent, tProperty&gt; *cProperty,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  tProperty *&amp;tVariable,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  GET_PROP Get_Property,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  SET_PROP Set_Property)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cProperty-&gt;m_Property = new tProperty;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *cProperty-&gt;m_Property = NULL;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tVariable = cProperty-&gt;m_Property;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cProperty-&gt;m_Parent = cParent;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cProperty-&gt;m_Copy = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cProperty-&gt;m_Get_Property = Get_Property;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cProperty-&gt;m_Set_Property = Set_Property;<br />
&nbsp; &nbsp; &nbsp; &nbsp; };<br />
};<br />
<br />
template &lt;class tParent, class tProperty&gt;<br />
class Property<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; typedef tProperty (tParent::*GET_PROP)(tParent*);<br />
&nbsp; &nbsp; &nbsp; &nbsp; typedef void (tParent::*SET_PROP)(tParent*, tProperty);<br />
<br />
public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; friend class InitProp&lt;tParent, tProperty&gt;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Property()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_Parent = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_Set_Property = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_Get_Property = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; };<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ~Property()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (m_Copy-- == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delete m_Property;<br />
&nbsp; &nbsp; &nbsp; &nbsp; };<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Property operator= (tProperty NewValue)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (m_Set_Property != NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (m_Parent-&gt;*m_Set_Property)(m_Parent, NewValue);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return *this;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Property(const Property&amp; Prop)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ++m_Copy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; };<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; operator tProperty()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (m_Get_Property != NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (m_Parent-&gt;*m_Get_Property)(m_Parent);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; };<br />
<br />
private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; int m_Copy;<br />
&nbsp; &nbsp; &nbsp; &nbsp; tParent *m_Parent;<br />
&nbsp; &nbsp; &nbsp; &nbsp; tProperty *m_Property;<br />
&nbsp; &nbsp; &nbsp; &nbsp; GET_PROP m_Get_Property;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SET_PROP m_Set_Property;<br />
};<br />
<br />
class Form<br />
{<br />
public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Property&lt;Form, LPCWSTR&gt; Title;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Form()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InitProp&lt;Form, LPCWSTR&gt; pTitle(this, &amp;Title, m_Title, &amp;Form::g_Title, &amp;Form::s_Title);<br />
&nbsp; &nbsp; &nbsp; &nbsp; };<br />
<br />
private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; LPCWSTR *m_Title;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; LPCWSTR g_Title(Form *Sender)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // User called Form.Title<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return *Sender-&gt;m_Title;<br />
&nbsp; &nbsp; &nbsp; &nbsp; };<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; void s_Title(Form *Sender, LPCWSTR NewValue)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // User set Form.Title =<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *Sender-&gt;m_Title = NewValue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; };<br />
<br />
};<br />
<br />
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Form *frmMain;<br />
&nbsp; &nbsp; &nbsp; &nbsp; frmMain = new Form;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; frmMain-&gt;Title = L&quot;This is just a test!&quot;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; MessageBox(NULL, frmMain-&gt;Title, NULL, 0);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; delete frmMain;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</code><hr />
</div> So far this code only works with the <i>LPCWSTR</i> type (<i>const wchar_t*</i>). Unfortunately I got to this stage using only that type, and now when I try another type, such as <i>int</i>, it fails. When using the <i>int</i> type I believe it creates an error because the constructor of <b>InitProp</b> expects a type of pointer to be parsed. When I try using it with <b>int*</b> type (the private variable then becoming <i>int **m_Variable</i>) it compiles, thought I cannot access the property like a normal <b>int</b>.<br />
<br />
My best guess from here is that I probably have to overload the <b>InitProp</b> constructor in a way that it can setup the <b>Property</b> classes for base-types and pointer-types, and then also modify the <b>Property</b> class to handle both.<br />
<br />
I'd appreciate any suggestions and input as I'm becoming lost in template-&gt;pointer-land.<br />
<br />
Thanks!</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>FrOzeN89</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537037-Creating-a-Property-(Get-Set)-Class</guid>
		</item>
		<item>
			<title>Problem about file handling!!!</title>
			<link>http://forums.codeguru.com/showthread.php?537031-Problem-about-file-handling!!!&amp;goto=newpost</link>
			<pubDate>Thu, 16 May 2013 05:09:08 GMT</pubDate>
			<description><![CDATA[Every time I write in file using ofstream it works fine except for one thing that when the file is re-opened after writing something and we try to add more data then previously added data is removed how to get rid of this.

<code>


struct abc
{
   char name[100]; 
   int a;     
};


int main()
{
    
    
   ofstream file;
   file.open("text.dat", ios::out | ios::binary);
   
   
   abc x;
   
   
   
   x.a = 2;   
   cout<<"Enter name ";
   cin>>x.name;   
   
   
   
   file.write((char*)&x,sizeof(struct abc));
   file.close();
    
 getch();
 return 0;   
}

</code>]]></description>
			<content:encoded><![CDATA[<div>Every time I write in file using ofstream it works fine except for one thing that when the file is re-opened after writing something and we try to add more data then previously added data is removed how to get rid of this.<br />
<br />
&lt;code&gt;<br />
<br />
<br />
struct abc<br />
{<br />
   char name[100]; <br />
   int a;     <br />
};<br />
<br />
<br />
int main()<br />
{<br />
    <br />
    <br />
   ofstream file;<br />
   file.open(&quot;text.dat&quot;, ios::out | ios::binary);<br />
   <br />
   <br />
   abc x;<br />
   <br />
   <br />
   <br />
   x.a = 2;   <br />
   cout&lt;&lt;&quot;Enter name &quot;;<br />
   cin&gt;&gt;x.name;   <br />
   <br />
   <br />
   <br />
   file.write((char*)&amp;x,sizeof(struct abc));<br />
   file.close();<br />
    <br />
 getch();<br />
 return 0;   <br />
}<br />
<br />
&lt;/code&gt;</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>labeeb_ahmad</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537031-Problem-about-file-handling!!!</guid>
		</item>
		<item>
			<title>Link time errors for static members</title>
			<link>http://forums.codeguru.com/showthread.php?537027-Link-time-errors-for-static-members&amp;goto=newpost</link>
			<pubDate>Thu, 16 May 2013 04:30:53 GMT</pubDate>
			<description><![CDATA[
Code:
---------
    class NavMeshLoader
    {
    public:
            NavMeshLoader()
            {
                    m_navMesh = loadAll("all_tiles_navmesh.bin");
                    m_navQuery->init(m_navMesh, 2048);
            }
    public:
            dtNavMesh *loadAll(const std::string& path)
            {
                    FILE* fp = fopen(path.c_str(), "rb");
                    if (!fp) return 0;
           
                    // Read header.
                    NavMeshSetHeader header;
                    fread(&header, sizeof(NavMeshSetHeader), 1, fp);
                    if (header.magic != NAVMESHSET_MAGIC)
                    {
                            fclose(fp);
                            return 0;
                    }
                    if (header.version != NAVMESHSET_VERSION)
                    {
                            fclose(fp);
                            return 0;
                    }
           
                    dtNavMesh* mesh = dtAllocNavMesh();
                    if (!mesh)
                    {
                            fclose(fp);
                            return 0;
                    }
                    dtStatus status = mesh->init(&header.params);
                    if (dtStatusFailed(status))
                    {
                            fclose(fp);
                            return 0;
                    }
                   
                    // Read tiles.
                    for (int i = 0; i < header.numTiles; ++i)
                    {
                            NavMeshTileHeader tileHeader;
                            fread(&tileHeader, sizeof(tileHeader), 1, fp);
                            if (!tileHeader.tileRef || !tileHeader.dataSize)
                                    break;

                            unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM);
                            if (!data) break;
                            memset(data, 0, tileHeader.dataSize);
                            fread(data, tileHeader.dataSize, 1, fp);
                   
                            mesh->addTile(data, tileHeader.dataSize, DT_TILE_FREE_DATA, tileHeader.tileRef, 0);
                    }
           
                    fclose(fp);
           
                    return mesh;
            }

    private:
            // By reference only, no memory consumption
            static dtNavMesh *m_navMesh;
                      
            static dtNavMeshQuery* m_navQuery;

            static dtQueryFilter m_filter;

            static dtStatus m_pathFindStatus;
    };
---------
 
Error        3        error LNK2001: unresolved external symbol "private: static class dtNavMesh * NavMeshLoader::m_navMesh" (?m_navMesh@NavMeshLoader@@0PAVdtNavMesh@@A)        D:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\PerfectSim\main.obj        PerfectSim
Error        2        error LNK2001: unresolved external symbol "private: static class dtNavMeshQuery * NavMeshLoader::m_navQuery" (?m_navQuery@NavMeshLoader@@0PAVdtNavMeshQuery@@A)        D:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\PerfectSim\main.obj        PerfectSim]]></description>
			<content:encoded><![CDATA[<div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&nbsp; &nbsp; class NavMeshLoader<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NavMeshLoader()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_navMesh = loadAll(&quot;all_tiles_navmesh.bin&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_navQuery-&gt;init(m_navMesh, 2048);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dtNavMesh *loadAll(const std::string&amp; path)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FILE* fp = fopen(path.c_str(), &quot;rb&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!fp) return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Read header.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NavMeshSetHeader header;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fread(&amp;header, sizeof(NavMeshSetHeader), 1, fp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (header.magic != NAVMESHSET_MAGIC)<br />
&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; fclose(fp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (header.version != NAVMESHSET_VERSION)<br />
&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; fclose(fp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dtNavMesh* mesh = dtAllocNavMesh();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!mesh)<br />
&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; fclose(fp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dtStatus status = mesh-&gt;init(&amp;header.params);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (dtStatusFailed(status))<br />
&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; fclose(fp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Read tiles.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; header.numTiles; ++i)<br />
&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; NavMeshTileHeader tileHeader;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fread(&amp;tileHeader, sizeof(tileHeader), 1, fp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!tileHeader.tileRef || !tileHeader.dataSize)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!data) break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; memset(data, 0, tileHeader.dataSize);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fread(data, tileHeader.dataSize, 1, fp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mesh-&gt;addTile(data, tileHeader.dataSize, DT_TILE_FREE_DATA, tileHeader.tileRef, 0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fclose(fp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return mesh;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // By reference only, no memory consumption<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; static dtNavMesh *m_navMesh;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; static dtNavMeshQuery* m_navQuery;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; static dtQueryFilter m_filter;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; static dtStatus m_pathFindStatus;<br />
&nbsp; &nbsp; };</code><hr />
</div> Error        3        error LNK2001: unresolved external symbol &quot;private: static class dtNavMesh * NavMeshLoader::m_navMesh&quot; (?m_navMesh@NavMeshLoader@@0PAVdtNavMesh@@A)        D:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\PerfectSim\main.obj        PerfectSim<br />
Error        2        error LNK2001: unresolved external symbol &quot;private: static class dtNavMeshQuery * NavMeshLoader::m_navQuery&quot; (?m_navQuery@NavMeshLoader@@0PAVdtNavMeshQuery@@A)        D:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\PerfectSim\main.obj        PerfectSim</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>lucky6969b</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537027-Link-time-errors-for-static-members</guid>
		</item>
		<item>
			<title>Member function pointer assignment</title>
			<link>http://forums.codeguru.com/showthread.php?537011-Member-function-pointer-assignment&amp;goto=newpost</link>
			<pubDate>Wed, 15 May 2013 16:13:10 GMT</pubDate>
			<description><![CDATA[I have a class with member functions and a pointer like this:

Code:
---------
class MyClass{
private:
    typedef void(MyClass::*memFnPtr_t) (); 
public:
    memFnPtr_t fnptr;
    void fn1();
    void fn2();
};
---------
Now in a regular function I create an instance of the class and try to assign the pointer:

Code:
---------
MyClass mc;
mc.fnptr = &mc.fn1;
---------
The compiler does not like it and suggests this instead:

Code:
---------
mc.fnptr = &MyClass::fn1;
---------
This seems to work but what if I have two instances of the class:

Code:
---------
MyClass mc1, mc2;
---------
How does the compiler know to distinguish between

Code:
---------
mc1.fn1
---------
and

Code:
---------
mc2.fn1
---------
when the assignment now looks identical:

Code:
---------
mc1.fnptr = &MyClass::fn1;
mc2.fnptr = &MyClass::fn1;
---------
?

:confused:

Thanks in advance!]]></description>
			<content:encoded><![CDATA[<div>I have a class with member functions and a pointer like this:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">class MyClass{<br />
private:<br />
&nbsp; &nbsp; typedef void(MyClass::*memFnPtr_t) (); <br />
public:<br />
&nbsp; &nbsp; memFnPtr_t fnptr;<br />
&nbsp; &nbsp; void fn1();<br />
&nbsp; &nbsp; void fn2();<br />
};</code><hr />
</div> Now in a regular function I create an instance of the class and try to assign the pointer:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">MyClass mc;<br />
mc.fnptr = &amp;mc.fn1;</code><hr />
</div> The compiler does not like it and suggests this instead:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">mc.fnptr = &amp;MyClass::fn1;</code><hr />
</div> This seems to work but what if I have two instances of the class:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">MyClass mc1, mc2;</code><hr />
</div> How does the compiler know to distinguish between<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">mc1.fn1</code><hr />
</div> and<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">mc2.fn1</code><hr />
</div> when the assignment now looks identical:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">mc1.fnptr = &amp;MyClass::fn1;<br />
mc2.fnptr = &amp;MyClass::fn1;</code><hr />
</div> ?<br />
<br />
:confused:<br />
<br />
Thanks in advance!</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>acppdummy</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537011-Member-function-pointer-assignment</guid>
		</item>
		<item>
			<title>A Predator-Prey Simulation</title>
			<link>http://forums.codeguru.com/showthread.php?537005-A-Predator-Prey-Simulation&amp;goto=newpost</link>
			<pubDate>Wed, 15 May 2013 11:03:49 GMT</pubDate>
			<description><![CDATA[Let there be two fishes named Kernighans and Ritchies. The only fish know to prey on Ritchies and to be able to digest them is the colour-blind Kernighan. The Kernighan has adapted to a diet of Ritchies, and won't prey on any other species. No other fish or sea animal could prey on the Ritchies.

So with he above information, could a simulation be created to calculate the two population at different time intervals. I have done something but i belive that i could be on the wrong track. 

Some other information to follow would be: 

The population of Kernighans and Ritchies can be fully determined by the population size of Kernighans and Ritchies. Suppose that in a given month the number of Kernighan is pop_k, and the population of Ritchies is pop_r. The population of Kernighans and Ritchies is measured in multiples of 1000. This means a population size of 1.0 corresponds to 1000 fish. For the number of Kernighans in the next month we have:  

	The population pop_k decreases by alpha_k  pop_k. This is the number of Kernighans that would starve if there were no Ritchies to eat.
The population pop_k increases by beta_k  pop_k  pop_r. This is the number of new Kernighans because they can feed on Ritchies.
The population pop_k decreases by gamma_k  pop_k2. This decrease in the number of Kernighans is due to competition between Kernighans.

Hence, given a population pop_k, the population in the next month is
pop_k - alpha_k  pop_k + beta_k  pop_k  pop_r - gamma_k.pop_k2
If the result of this computation is smaller than 0.001, then there are no Kernighan fish left

For the number of Ritchies in the next month we have

The population pop_r increases by alpha_r  pop_r. This is the number of new Ritchies, if there were no Kernighan to eat them..
 The population pop_r decreases by beta_r  pop_k  pop_r. This is the number of Ritcchies eaten by Kernighans.
 The population pop_r decreases by gamma_r  pop_r2. This decrease in the number of Ritcchies tis due to competition between Ritchies.

Hence, given a population pop_r the population in the next month is

 pop_r + alpha_r.pop_r - beta_r.pop_k.pop_r - gamma_r.pop_r 2
 If the result of this computation is smaller than 0.001, then there are no Ritchie fish left.

Measurements have shown that the constants have the following values:
 alpha_k = 0.4;
 beta_k = 0.4
 gamma_k=0.036
 alpha_r = 0.2;
 beta_r = 0.2
 gamma_r=0.036]]></description>
			<content:encoded><![CDATA[<div>Let there be two fishes named Kernighans and Ritchies. The only fish know to prey on Ritchies and to be able to digest them is the colour-blind Kernighan. The Kernighan has adapted to a diet of Ritchies, and won't prey on any other species. No other fish or sea animal could prey on the Ritchies.<br />
<br />
So with he above information, could a simulation be created to calculate the two population at different time intervals. I have done something but i belive that i could be on the wrong track. <br />
<br />
Some other information to follow would be: <br />
<br />
The population of Kernighans and Ritchies can be fully determined by the population size of Kernighans and Ritchies. Suppose that in a given month the number of Kernighan is pop_k, and the population of Ritchies is pop_r. The population of Kernighans and Ritchies is measured in multiples of 1000. This means a population size of 1.0 corresponds to 1000 fish. For the number of Kernighans in the next month we have:  <br />
<br />
	The population pop_k decreases by alpha_k  pop_k. This is the number of Kernighans that would starve if there were no Ritchies to eat.<br />
The population pop_k increases by beta_k  pop_k  pop_r. This is the number of new Kernighans because they can feed on Ritchies.<br />
The population pop_k decreases by gamma_k  pop_k2. This decrease in the number of Kernighans is due to competition between Kernighans.<br />
<br />
Hence, given a population pop_k, the population in the next month is<br />
pop_k - alpha_k  pop_k + beta_k  pop_k  pop_r - gamma_k.pop_k2<br />
If the result of this computation is smaller than 0.001, then there are no Kernighan fish left<br />
<br />
For the number of Ritchies in the next month we have<br />
<br />
The population pop_r increases by alpha_r  pop_r. This is the number of new Ritchies, if there were no Kernighan to eat them..<br />
 The population pop_r decreases by beta_r  pop_k  pop_r. This is the number of Ritcchies eaten by Kernighans.<br />
 The population pop_r decreases by gamma_r  pop_r2. This decrease in the number of Ritcchies tis due to competition between Ritchies.<br />
<br />
Hence, given a population pop_r the population in the next month is<br />
<br />
 pop_r + alpha_r.pop_r - beta_r.pop_k.pop_r - gamma_r.pop_r 2<br />
 If the result of this computation is smaller than 0.001, then there are no Ritchie fish left.<br />
<br />
Measurements have shown that the constants have the following values:<br />
 alpha_k = 0.4;<br />
 beta_k = 0.4<br />
 gamma_k=0.036<br />
 alpha_r = 0.2;<br />
 beta_r = 0.2<br />
 gamma_r=0.036</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>rockx</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537005-A-Predator-Prey-Simulation</guid>
		</item>
		<item>
			<title>Circular Dependency  error</title>
			<link>http://forums.codeguru.com/showthread.php?537003-Circular-Dependency-error&amp;goto=newpost</link>
			<pubDate>Wed, 15 May 2013 09:53:20 GMT</pubDate>
			<description><![CDATA[Hi ,

I was doing Uni assignment ( not looking for a full solution ) had to use the start up code provided ( other wise this issue would not have come ),
when compiling the source  I get the following  error  

"pms_program.h:54:56: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;CourseType&#8217;" 

the code you are looking for in  pms_course.h  ( there is a circular dependency  between  pms.h , pms_course.h and pms_program.h)
Head tutor provided a GUARD however  don't think it works properly

function prototype AppendProgram  ( part of doubly linked list )



I have attached the full course code.

As much as I like I cannot change the structure of the startup  code , I was hoping that someone know a  solution or cam point me to the problem

please see attached zip file for the entire source code.

Thanks for Stopping by.]]></description>
			<content:encoded><![CDATA[<div>Hi ,<br />
<br />
I was doing Uni assignment ( not looking for a full solution ) had to use the start up code provided ( other wise this issue would not have come ),<br />
when compiling the source  I get the following  error  <br />
<br />
&quot;pms_program.h:54:56: error: expected declaration specifiers or &#8216;...&#8217; before &#8216;CourseType&#8217;&quot; <br />
<br />
the code you are looking for in  pms_course.h  ( there is a circular dependency  between  pms.h , pms_course.h and pms_program.h)<br />
Head tutor provided a GUARD however  don't think it works properly<br />
<br />
function prototype AppendProgram  ( part of doubly linked list )<br />
<br />
<br />
<br />
I have attached the full course code.<br />
<br />
As much as I like I cannot change the structure of the startup  code , I was hoping that someone know a  solution or cam point me to the problem<br />
<br />
please see attached zip file for the entire source code.<br />
<br />
Thanks for Stopping by.</div>


	<div style="padding:10px">

	

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Files</legend>
			<ul>
			<li>
	<img class="inlineimg" src="/zip.gif" alt="File Type: zip" />
	<a href="http://forums.codeguru.com/attachment.php?attachmentid=31427&amp;d=1368611332">pms.zip&lrm;</a> 
(7.9 KB)
</li> 
			</ul>
		</fieldset>
	

	</div>
 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>aamir121a</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537003-Circular-Dependency-error</guid>
		</item>
		<item>
			<title>Design advice required</title>
			<link>http://forums.codeguru.com/showthread.php?537001-Design-advice-required&amp;goto=newpost</link>
			<pubDate>Wed, 15 May 2013 09:47:58 GMT</pubDate>
			<description>I am trying to design and implement a program that consists of two classes.  The Base class A is purely for supporting class B.  I do not want to be able to create an object of class A.  When object B is created it inherits from class A.  

What is the best way to achieve this?</description>
			<content:encoded><![CDATA[<div>I am trying to design and implement a program that consists of two classes.  The Base class A is purely for supporting class B.  I do not want to be able to create an object of class A.  When object B is created it inherits from class A.  <br />
<br />
What is the best way to achieve this?</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>Gerald Bates</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?537001-Design-advice-required</guid>
		</item>
		<item>
			<title>Read from file</title>
			<link>http://forums.codeguru.com/showthread.php?536935-Read-from-file&amp;goto=newpost</link>
			<pubDate>Sun, 12 May 2013 18:01:16 GMT</pubDate>
			<description><![CDATA[Hello.
I want my program to read variables from file "input.txt":

---Quote---
Please choose the crystal lattice. Type 1 for BCC, 2 for FCC, and 3 for HCP: 2
Please enter lattice parameter (a): 1
For HCP please enter second lattice parameter (c): 1
Please enter the number of translated cells along X axis: 2
Please enter the number of translated cells along Y axis: 2
Please enter the number of translated cells along Z axis: 2
---End Quote---
Moreover, I want program to read only the numbers after colon. How can I do it?

Code:
---------
#include <iostream>#include <fstream> // to read from file
 
using namespace std;
 
int main ()
{
    int latticeType;
    int dimX, dimY, dimZ; // number of translated cells along each axis
    float d; // lattice parameter
    float h; // second lattice parameter for HCP
    ifstream inputFile; // object of class 'ifstream' to read from it
 
    inputFile.open("input.txt", ios::in); // open 'input.txt' only for reading
    if (!inputFile){
        cerr << "Unable to open input file";
        return -1;
    }
    while (!inputFile.eof()){
        inputFile >> latticeType;
        cout << latticeType << endl;
    if ( (latticeType!=1) && (latticeType!=2) && (latticeType!=3) ){
        cerr << "Invalid value of lattice type" << endl;
        return -1;
    }
        inputFile >> d;
        cout << d << endl;
        if (latticeType==3){
            inputFile >> h;
            cout << d << endl;
        }
        inputFile >> dimX;
        cout << dimX;
        inputFile >> dimY;
        cout << dimY;
        inputFile >> dimZ;
        cout << dimZ;
    }
    inputFile.close();
 
    return 0;
}
---------
]]></description>
			<content:encoded><![CDATA[<div>Hello.<br />
I want my program to read variables from file &quot;input.txt&quot;:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Quote:</div>
	<div class="bbcode_quote printable">
		<hr />
		
			<font color="#000000"><span style="font-family: Verdana">Please choose the crystal lattice. Type 1 for BCC, 2 for FCC, and 3 for HCP: 2</span></font><br />
<font color="#000000"><span style="font-family: Verdana">Please enter lattice parameter (a): 1</span></font><br />
<font color="#000000"><span style="font-family: Verdana">For HCP please enter second lattice parameter (c): 1</span></font><br />
<font color="#000000"><span style="font-family: Verdana">Please enter the number of translated cells along X axis: 2</span></font><br />
<font color="#000000"><span style="font-family: Verdana">Please enter the number of translated cells along Y axis: 2</span></font><br />
<font color="#000000"><span style="font-family: Verdana">Please enter the number of translated cells along Z axis: 2</span></font>
			
		<hr />
	</div>
</div> Moreover, I want program to read only the numbers after colon. How can I do it?<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">#include &lt;iostream&gt;#include &lt;fstream&gt; // to read from file<br />
&nbsp;<br />
using namespace std;<br />
&nbsp;<br />
int main ()<br />
{<br />
&nbsp; &nbsp; int latticeType;<br />
&nbsp; &nbsp; int dimX, dimY, dimZ; // number of translated cells along each axis<br />
&nbsp; &nbsp; float d; // lattice parameter<br />
&nbsp; &nbsp; float h; // second lattice parameter for HCP<br />
&nbsp; &nbsp; ifstream inputFile; // object of class 'ifstream' to read from it<br />
&nbsp;<br />
&nbsp; &nbsp; inputFile.open(&quot;input.txt&quot;, ios::in); // open 'input.txt' only for reading<br />
&nbsp; &nbsp; if (!inputFile){<br />
&nbsp; &nbsp; &nbsp; &nbsp; cerr &lt;&lt; &quot;Unable to open input file&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return -1;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; while (!inputFile.eof()){<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputFile &gt;&gt; latticeType;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; latticeType &lt;&lt; endl;<br />
&nbsp; &nbsp; if ( (latticeType!=1) &amp;&amp; (latticeType!=2) &amp;&amp; (latticeType!=3) ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; cerr &lt;&lt; &quot;Invalid value of lattice type&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return -1;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputFile &gt;&gt; d;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; d &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (latticeType==3){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputFile &gt;&gt; h;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; d &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputFile &gt;&gt; dimX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; dimX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputFile &gt;&gt; dimY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; dimY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputFile &gt;&gt; dimZ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; dimZ;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; inputFile.close();<br />
&nbsp;<br />
&nbsp; &nbsp; return 0;<br />
}</code><hr />
</div> </div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>ted_kingdom</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536935-Read-from-file</guid>
		</item>
		<item>
			<title>Linked List problem</title>
			<link>http://forums.codeguru.com/showthread.php?536925-Linked-List-problem&amp;goto=newpost</link>
			<pubDate>Sat, 11 May 2013 16:55:50 GMT</pubDate>
			<description><![CDATA[
Code:
---------
#include <stdio.h>
#include <stdlib.h>


typedef struct Node
{
	int data;
	struct Node *next;
}node;

void insert(node **ptrtohead, int val)
{
   node *temp=(node*)malloc(sizeof(node));


		*ptrtohead=temp;   
		temp->data=val;

		temp->next=NULL;
  	
 	 if(*ptrtohead != NULL)
   	{
   	
   
		temp->next=*ptrtohead;
		*ptrtohead=temp; 
     }
     

}

void display(node *start)
{
	while(start!=NULL)
	{
	
		printf("%d ",start->data);
	   start= start->next;
		
	}
}

int main(int argc, char *argv[])
{
  
  
  node *head=NULL;

	insert(&head,10);
	insert(&head,20);
	display(head);
  
  system("PAUSE");	
  return 0;
}
---------
   I don't know where is the problem, the output is infinite number of 10 !!!! Help is very much appreciated.]]></description>
			<content:encoded><![CDATA[<div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
<br />
typedef struct Node<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int data;<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct Node *next;<br />
}node;<br />
<br />
void insert(node **ptrtohead, int val)<br />
{<br />
&nbsp;  node *temp=(node*)malloc(sizeof(node));<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *ptrtohead=temp;&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;data=val;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;next=NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(*ptrtohead != NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;next=*ptrtohead;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *ptrtohead=temp; <br />
&nbsp; &nbsp;  }<br />
&nbsp; &nbsp;  <br />
<br />
}<br />
<br />
void display(node *start)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(start!=NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d &quot;,start-&gt;data);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  start= start-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
int main(int argc, char *argv[])<br />
{<br />
&nbsp; <br />
&nbsp; <br />
&nbsp; node *head=NULL;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; insert(&amp;head,10);<br />
&nbsp; &nbsp; &nbsp; &nbsp; insert(&amp;head,20);<br />
&nbsp; &nbsp; &nbsp; &nbsp; display(head);<br />
&nbsp; <br />
&nbsp; system(&quot;PAUSE&quot;);&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; return 0;<br />
}</code><hr />
</div>    I don't know where is the problem, the output is infinite number of 10 !!!! Help is very much appreciated.</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>dotnet13</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536925-Linked-List-problem</guid>
		</item>
		<item>
			<title>C++ easy school project, I need help</title>
			<link>http://forums.codeguru.com/showthread.php?536921-C-easy-school-project-I-need-help&amp;goto=newpost</link>
			<pubDate>Sat, 11 May 2013 09:40:45 GMT</pubDate>
			<description><![CDATA[*Hello there! *

I am having trouble in school with some basic and easy (not for me) C++ programming.
If you could help me, I need codes for these programs to pass a high school grade. I study IT school, but I study multimedia and presentation, but they want basic programming too and I have no idea what to do with it.

*Thanks for any help guys!*

Create a program, which determines every prime number in interval <1;100> and then print to screen:
Prime numbers in range 1  100
number of prime numbers: NN
prime numbers: N N N N N N N N  N

http://prntscr.com/14dmw1 (this is printscreen for another project, by operator I mean + - * /)

Create program, which declarates field formed by matrix named OKTO[8;8]. Matrixs elements will be saved to file named OKTO_DATA, from element 1,1 to 8,8 where 1,1 to 1,8 is one entry.
For calculation value of elements you have to apply I+1 is double of I.

http://wikisend.com/download/135354/moonlanding.jpg (link for image of flowchart)

I beg anyone who can help me to help me, I know really nothing about programming, so I cant discuss this :(
any help will save my pass to another year of high school, I would be very very very thankfull if anyone helps.
PS: sorry for grammar or any english mistakes, it isnt my native language.]]></description>
			<content:encoded><![CDATA[<div><b>Hello there! </b><br />
<br />
I am having trouble in school with some basic and easy (not for me) C++ programming.<br />
If you could help me, I need codes for these programs to pass a high school grade. I study IT school, but I study multimedia and presentation, but they want basic programming too and I have no idea what to do with it.<br />
<br />
<b>Thanks for any help guys!</b><br />
<br />
Create a program, which determines every prime number in interval &lt;1;100&gt; and then print to screen:<br />
Prime numbers in range 1  100<br />
number of prime numbers: NN<br />
prime numbers: N N N N N N N N  N<br />
<br />
<a rel="nofollow" href="http://prntscr.com/14dmw1" target="_blank">http://prntscr.com/14dmw1</a> (this is printscreen for another project, by operator I mean + - * /)<br />
<br />
Create program, which declarates field formed by matrix named OKTO[8;8]. Matrixs elements will be saved to file named OKTO_DATA, from element 1,1 to 8,8 where 1,1 to 1,8 is one entry.<br />
For calculation value of elements you have to apply I+1 is double of I.<br />
<br />
<a rel="nofollow" href="http://wikisend.com/download/135354/moonlanding.jpg" target="_blank">http://wikisend.com/download/135354/moonlanding.jpg</a> (link for image of flowchart)<br />
<br />
I beg anyone who can help me to help me, I know really nothing about programming, so I cant discuss this :(<br />
any help will save my pass to another year of high school, I would be very very very thankfull if anyone helps.<br />
PS: sorry for grammar or any english mistakes, it isnt my native language.</div>

 ]]></content:encoded>
			<category domain="http://forums.codeguru.com/forumdisplay.php?9-C-(Non-Visual-C-Issues)">C++  (Non Visual C++ Issues)</category>
			<dc:creator>delivium</dc:creator>
			<guid isPermaLink="true">http://forums.codeguru.com/showthread.php?536921-C-easy-school-project-I-need-help</guid>
		</item>
	</channel>
</rss>
