<?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</title>
		<link>http://www.codeguru.com/forum</link>
		<description>Hard hitting articles, dicussions, resources, and more all focusing for real developers in the real world.</description>
		<language>en</language>
		<lastBuildDate>Sat, 21 Nov 2009 22:45:11 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.codeguru.com/forum/images/misc/rss.jpg</url>
			<title>CodeGuru Forums</title>
			<link>http://www.codeguru.com/forum</link>
		</image>
		<item>
			<title>Range wont work?</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488601&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 22:15:19 GMT</pubDate>
			<description>I want my code to print numbers 1 through 10, only if the input is 1 through 10.
so if the user inputs 4, i want the numbers 1-10 to print.</description>
			<content:encoded><![CDATA[<div>I want my code to print numbers 1 through 10, only if the input is 1 through 10.<br />
so if the user inputs 4, i want the numbers 1-10 to print.</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=7">Visual C++ Programming</category>
			<dc:creator>eddied</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488601</guid>
		</item>
		<item>
			<title>class</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488600&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 21:35:08 GMT</pubDate>
			<description>from a generic class inside a mfc project like to check if a dialog is up. If it is then access its first page , page0, members. dialog is inherited from CMyPropertySheet. i need actual code example.</description>
			<content:encoded><![CDATA[<div>from a generic class inside a mfc project like to check if a dialog is up. If it is then access its first page , page0, members. dialog is inherited from CMyPropertySheet. i need actual code example.</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=7">Visual C++ Programming</category>
			<dc:creator>QAG</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488600</guid>
		</item>
		<item>
			<title>Help with code</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488599&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 21:20:14 GMT</pubDate>
			<description><![CDATA[I need some help with this code:

Private Sub Timer3_Timer()
' The Packet Sender / Retriever Send/Return Time system
' Made 23:33 20.11.2009
' PSR v1.0
If Combo1.List(0) = "Signal" Then
       dblTime = Timer
  Else
If Combo1.List(0) = "Signal Return" Then
Label3.Caption = Timer - dblTime & " seconds"
dblTime = 0
End If
End If
End Sub

For some reason it doesent print out the right 'time' on label3.The time shuld be line 0.1/0.2 but now it prints out 8213.1 and something like that.]]></description>
			<content:encoded><![CDATA[<div>I need some help with this code:<br />
<br />
Private Sub Timer3_Timer()<br />
' The Packet Sender / Retriever Send/Return Time system<br />
' Made 23:33 20.11.2009<br />
' PSR v1.0<br />
If Combo1.List(0) = &quot;Signal&quot; Then<br />
       dblTime = Timer<br />
  Else<br />
If Combo1.List(0) = &quot;Signal Return&quot; Then<br />
Label3.Caption = Timer - dblTime &amp; &quot; seconds&quot;<br />
dblTime = 0<br />
End If<br />
End If<br />
End Sub<br />
<br />
For some reason it doesent print out the right 'time' on label3.The time shuld be line 0.1/0.2 but now it prints out 8213.1 and something like that.</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=4">Visual Basic 6.0 Programming</category>
			<dc:creator>Equx</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488599</guid>
		</item>
		<item>
			<title>Old famous problem of killing a thread</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488598&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 20:46:29 GMT</pubDate>
			<description>Hi everyone.
I have an AbstractAgent object which implements Runnable. 
The run() method just calls the abstract method iterate() which is implemented by the child Agent.
The AbstractAgent allows the child Agent access to a private mailbox through a final blocking method getMessage().
I want to kill this thread by sending it a killMessage when it is waiting on a mailbox.
My scheme is when getting a killMessage, throw an exception which will be caught inside the run() method.
The thing is that althugh the exception is created and thrown inside getMessage() and caught inside run(), which are both implemented at the base class, its route is through the child class, which I want for security reasons to be unable to catch or handle the exception. The child class must allow the exception to propagate gracefully to my handler.
Is it possible to implement this? Prevent the child class to handle exceptions that are created and caught inside the base class?

Thanks
Guy</description>
			<content:encoded><![CDATA[<div>Hi everyone.<br />
I have an <i>AbstractAgent</i> object which implements <i>Runnable</i>. <br />
The <i>run()</i> method just calls the abstract method <i>iterate()</i> which is implemented by the child Agent.<br />
The <i>AbstractAgent</i> allows the child Agent access to a private mailbox through a final blocking method <i>getMessage()</i>.<br />
I want to kill this thread by sending it a <i>killMessage</i> when it is waiting on a mailbox.<br />
My scheme is when getting a <i>killMessage</i>, throw an exception which will be caught inside the <i>run()</i> method.<br />
The thing is that althugh the exception is created and thrown inside <i>getMessage()</i> and caught inside <i>run()</i>, which are both implemented at the base class, its route is through the child class, which I want for security reasons to be unable to catch or handle the exception. The child class must allow the exception to propagate gracefully to my handler.<br />
Is it possible to implement this? Prevent the child class to handle exceptions that are created and caught inside the base class?<br />
<br />
Thanks<br />
Guy</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=5">Java Programming</category>
			<dc:creator>guyafe</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488598</guid>
		</item>
		<item>
			<title>Need Help with a Forum Code</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488597&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 20:18:41 GMT</pubDate>
			<description><![CDATA[Ok the following code will create a click here to reveal in a post but I'm wanting to add another option. Right now [spoiler][/spoiler] uses this code

<span>
<span style="color:#FFF; background-color:#000;" onclick="this.style.display = 'none'; this.nextSibling.style.display = 'inline';">Click To Reveal
</span>
<span style="display:none;" onclick="this.style.display = 'none';this.previousSibling.style.display = 'inline';">{TEXT}
</span>
</span>

What I'm wanting to do is make another option like [spoiler=x] where x is a variable representing text naming the line (click here to reveal) with a title instead of just saying click here to reveal.

Before: Click to reveal
After: Human Artifacts List

Also if I wanted to put in a click to hide text I could change the 2nd part of the span code to:
<span style="color:#FFF; background-color:#000;;" onclick="this.style.display = 'none';this.previousSibling.style.display = 'inline';">Click to minimize{TEXT}
Does this start the text on the next line or will it look like:
Click to minimize blah blah?]]></description>
			<content:encoded><![CDATA[<div>Ok the following code will create a click here to reveal in a post but I'm wanting to add another option. Right now [spoiler][/spoiler] uses this code<br />
<br />
&lt;span&gt;<br />
&lt;span style=&quot;color:#FFF; background-color:#000;&quot; onclick=&quot;this.style.display = 'none'; this.nextSibling.style.display = 'inline';&quot;&gt;Click To Reveal<br />
&lt;/span&gt;<br />
&lt;span style=&quot;display:none;&quot; onclick=&quot;this.style.display = 'none';this.previousSibling.style.display = 'inline';&quot;&gt;{TEXT}<br />
&lt;/span&gt;<br />
&lt;/span&gt;<br />
<br />
What I'm wanting to do is make another option like [spoiler=x] where x is a variable representing text naming the line (click here to reveal) with a title instead of just saying click here to reveal.<br />
<br />
Before: Click to reveal<br />
After: Human Artifacts List<br />
<br />
Also if I wanted to put in a click to hide text I could change the 2nd part of the span code to:<br />
&lt;span style=&quot;color:#FFF; background-color:#000;;&quot; onclick=&quot;this.style.display = 'none';this.previousSibling.style.display = 'inline';&quot;&gt;Click to minimize{TEXT}<br />
Does this start the text on the next line or will it look like:<br />
Click to minimize blah blah?</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=8">Scripting - Client Side</category>
			<dc:creator>Megaladon</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488597</guid>
		</item>
		<item>
			<title>what is wrong with CFile and CSocket??</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488596&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 20:14:58 GMT</pubDate>
			<description><![CDATA[Hi!

I am using VC++ 2008. I have a multithreaded application that also uses sockets (CSocket).

There is a strange problem I have:
For the server program:
I open a file with CFile class (this is the server program), and I get its length, like this:

Code:
---------
DWORD nrParts = (DWORD)SendFile.GetLength() / 1024;
if (SendFile.GetLength() % 1024) nrParts++;
---------
I send the nrParts to the Client Program, and after some irrelevant code (like, QueryPerformanceCounter, etc. that do other stuff) I read from the file the first 1024 bytes. At this moment nrParts BECOMES 0!! I tried to save the nrParts after into another variable, that is const, like this:

Code:
---------
const DWORD count = nrParts;
---------
But EVEN count changes to 0.

For the client program:
I receive the nrParts variable correctly (in the client program its name is nrParts, as well).
BUT, after receiving the 1024 bytes (which I store in a BYTE vector called "data"), nrParts BECOMES 0! even if I save the nrParts into another variable declared with "const", i.e. "const DWORD count = nrParts;", even count becomes 0.

Can anybody please tell me what is happening?

PS: all this I have done in debug mode, step-by-step.]]></description>
			<content:encoded><![CDATA[<div>Hi!<br />
<br />
I am using VC++ 2008. I have a multithreaded application that also uses sockets (CSocket).<br />
<br />
There is a strange problem I have:<br />
For the server program:<br />
I open a file with CFile class (this is the server program), and I get its length, like this:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">DWORD nrParts = (DWORD)SendFile.GetLength() / 1024;<br />
if (SendFile.GetLength() % 1024) nrParts++;</code><hr />
</div>I send the nrParts to the Client Program, and after some irrelevant code (like, QueryPerformanceCounter, etc. that do other stuff) I read from the file the first 1024 bytes. At this moment nrParts BECOMES 0!! I tried to save the nrParts after into another variable, that is const, like this:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">const DWORD count = nrParts;</code><hr />
</div>But EVEN count changes to 0.<br />
<br />
For the client program:<br />
I receive the nrParts variable correctly (in the client program its name is nrParts, as well).<br />
BUT, after receiving the 1024 bytes (which I store in a BYTE vector called &quot;data&quot;), nrParts BECOMES 0! even if I save the nrParts into another variable declared with &quot;const&quot;, i.e. &quot;const DWORD count = nrParts;&quot;, even count becomes 0.<br />
<br />
Can anybody please tell me what is happening?<br />
<br />
PS: all this I have done in debug mode, step-by-step.</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=7">Visual C++ Programming</category>
			<dc:creator>Feoggou</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488596</guid>
		</item>
		<item>
			<title>CFileDialog problem</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488595&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 20:02:10 GMT</pubDate>
			<description>Hi!

I am having a problem with a filedialog.
I am using VC++ 2008.

this is the code with trouble:

Code:
---------
void CMyProgramDlg::OnBrowse()
{
	CFileDialog fdlg(TRUE, 0, 0, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, NULL, this, 0, 1);
	if (fdlg.DoModal() == IDOK)
        {
          //code
         }
}
---------
and somewhere in DoModal() it breaks and gives the following error message:

Code:
---------
First-chance exception at 0x779a64cf (ntdll.dll) in MyProgramHere.exe: 0xC0000008: An invalid handle was specified.
---------
I chose to break, and it follows:

Code:
---------
There is no source code available for the current location.
---------
when I look at the output window, I see:

Code:
---------
First-chance exception at 0x779a64cf (ntdll.dll) in MyProgramHere.exe.exe: 0xC0000008: An invalid handle was specified.
---------
more info: my program is multithreaded. this function is from the main thread. another thread is also running (started) in the same time. I am also using sockets.

and I CANNOT FIND WHAT EXACTLY IS THE PROBLEM.

can anybody please help me?</description>
			<content:encoded><![CDATA[<div>Hi!<br />
<br />
I am having a problem with a filedialog.<br />
I am using VC++ 2008.<br />
<br />
this is the code with trouble:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">void CMyProgramDlg::OnBrowse()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; CFileDialog fdlg(TRUE, 0, 0, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, NULL, this, 0, 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (fdlg.DoModal() == IDOK)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //code<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
}</code><hr />
</div>and somewhere in DoModal() it breaks and gives the following error message:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">First-chance exception at 0x779a64cf (ntdll.dll) in MyProgramHere.exe: 0xC0000008: An invalid handle was specified.</code><hr />
</div>I chose to break, and it follows:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">There is no source code available for the current location.</code><hr />
</div>when I look at the output window, I see:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">First-chance exception at 0x779a64cf (ntdll.dll) in MyProgramHere.exe.exe: 0xC0000008: An invalid handle was specified.</code><hr />
</div>more info: my program is multithreaded. this function is from the main thread. another thread is also running (started) in the same time. I am also using sockets.<br />
<br />
and I CANNOT FIND WHAT EXACTLY IS THE PROBLEM.<br />
<br />
can anybody please help me?</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=7">Visual C++ Programming</category>
			<dc:creator>Feoggou</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488595</guid>
		</item>
		<item>
			<title>can anyone help me to get the correct answer for this querstion????</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488593&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 19:20:05 GMT</pubDate>
			<description><![CDATA[i have build a program using c++ which has to collect information of customers. and it has to display information according to users request. 
it has to have 
1- customer id
2- customer name
3- address
4-  telephone number
5- credit limit.

it has to perform these functions.
 1- list of all customers
2- search by name
3- search by id
4- add new customers
5- display all the customers having credit amount above 5000.

I am posting the codes which i have built.... can someone help me to complete this question.. PLEASE.

CODE: 

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>

typedef struct customer {
        int id[20];
        char name[50];
        char address[80];
        char tele[15];
        float credlimit;
        } name;
        
# define MAX 999
name all_names[20];
int index=0;
int id=0;
         
int menu_Display ();
int get_Option (void);
int menu_Option (int option);
int get_Menu ();
int cust_Name(void);
int cust_id(void);
int cust_add(void);
 
int main () {
     menu_Display ();
     getch ();
   return 0;
}
 int menu_Display () {
     int choice=0;
     while (choice!=6) {
           get_Menu ();
           choice = get_Option();
           }}
    
int get_Menu (){
    printf ("\t1. Display information of all customers\n\n");
    printf ("\t2. Search for customer by Name\n\n");
    printf ("\t3. Search for customer by ID\n\n");
    printf ("\t4. Display a list of customers having credit limit above 5,000\n\n");
    printf ("\t5. Add new customer\n\n");
    printf ("\t6. Exit\n\n");
}
   

int get_Option (void) {
    
    int option;
    printf ("Please enter your option...");
    scanf ("%d", &option);
}
int menu_Option (int option) {
    int i;
    switch (option) {
           case 1 : cust_Name();
           break;
           case 2 : cust_id();
           break;
           case 3 : cust_add();
           break;
           case 6 : printf("The program will now exit\n");
           break;
           default : printf ("Sorry that does not exist");
           i=getchar();
           break;
           }
           }



int cust_Name(void) {
    int match;
    int i;
    int result;
    int loop=0;
    char name[20];
    
    printf("Please enter the name which you are searching for\n");
    gets(name);
    while (match == 0 && i < MAX) {
          result= strcmp(all_names[loop].name,name);
          loop++;
          }
          if (loop == MAX) {
                   printf ("Match not found\n");
                   }
          i=getchar();
          }
        
int cust_id(void) {
    int match;
    int i;
    int result=0;
    int loop=0;
    int id;
    
    printf ("Please enter the id number which you are searching for\n");
    scanf ("%d", &id);
    while (match == 0 && i< MAX) {
          result = strcmp (all_names[loop].id,id);
          loop++;
          }
          if (loop == MAX) {
                   printf ("Match not found");
                   }
          i = getchar();
          }
          
int cust_add(void) {
    printf("Enter the mew name\n");
    gets(all_names[index].name);
    
    all_names[index].id = id;
    index++;
    id++;
}


        
    
CODE ENDS HERE.]]></description>
			<content:encoded><![CDATA[<div>i have build a program using c++ which has to collect information of customers. and it has to display information according to users request. <br />
it has to have <br />
1- customer id<br />
2- customer name<br />
3- address<br />
4-  telephone number<br />
5- credit limit.<br />
<br />
it has to perform these functions.<br />
 1- list of all customers<br />
2- search by name<br />
3- search by id<br />
4- add new customers<br />
5- display all the customers having credit amount above 5000.<br />
<br />
I am posting the codes which i have built.... can someone help me to complete this question.. PLEASE.<br />
<br />
CODE: <br />
<br />
#include &lt;stdio.h&gt;<br />
#include &lt;conio.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
typedef struct customer {<br />
        int id[20];<br />
        char name[50];<br />
        char address[80];<br />
        char tele[15];<br />
        float credlimit;<br />
        } name;<br />
        <br />
# define MAX 999<br />
name all_names[20];<br />
int index=0;<br />
int id=0;<br />
         <br />
int menu_Display ();<br />
int get_Option (void);<br />
int menu_Option (int option);<br />
int get_Menu ();<br />
int cust_Name(void);<br />
int cust_id(void);<br />
int cust_add(void);<br />
 <br />
int main () {<br />
     menu_Display ();<br />
     getch ();<br />
   return 0;<br />
}<br />
 int menu_Display () {<br />
     int choice=0;<br />
     while (choice!=6) {<br />
           get_Menu ();<br />
           choice = get_Option();<br />
           }}<br />
    <br />
int get_Menu (){<br />
    printf (&quot;\t1. Display information of all customers\n\n&quot;);<br />
    printf (&quot;\t2. Search for customer by Name\n\n&quot;);<br />
    printf (&quot;\t3. Search for customer by ID\n\n&quot;);<br />
    printf (&quot;\t4. Display a list of customers having credit limit above 5,000\n\n&quot;);<br />
    printf (&quot;\t5. Add new customer\n\n&quot;);<br />
    printf (&quot;\t6. Exit\n\n&quot;);<br />
}<br />
   <br />
<br />
int get_Option (void) {<br />
    <br />
    int option;<br />
    printf (&quot;Please enter your option...&quot;);<br />
    scanf (&quot;%d&quot;, &amp;option);<br />
}<br />
int menu_Option (int option) {<br />
    int i;<br />
    switch (option) {<br />
           case 1 : cust_Name();<br />
           break;<br />
           case 2 : cust_id();<br />
           break;<br />
           case 3 : cust_add();<br />
           break;<br />
           case 6 : printf(&quot;The program will now exit\n&quot;);<br />
           break;<br />
           default : printf (&quot;Sorry that does not exist&quot;);<br />
           i=getchar();<br />
           break;<br />
           }<br />
           }<br />
<br />
<br />
<br />
int cust_Name(void) {<br />
    int match;<br />
    int i;<br />
    int result;<br />
    int loop=0;<br />
    char name[20];<br />
    <br />
    printf(&quot;Please enter the name which you are searching for\n&quot;);<br />
    gets(name);<br />
    while (match == 0 &amp;&amp; i &lt; MAX) {<br />
          result= strcmp(all_names[loop].name,name);<br />
          loop++;<br />
          }<br />
          if (loop == MAX) {<br />
                   printf (&quot;Match not found\n&quot;);<br />
                   }<br />
          i=getchar();<br />
          }<br />
        <br />
int cust_id(void) {<br />
    int match;<br />
    int i;<br />
    int result=0;<br />
    int loop=0;<br />
    int id;<br />
    <br />
    printf (&quot;Please enter the id number which you are searching for\n&quot;);<br />
    scanf (&quot;%d&quot;, &amp;id);<br />
    while (match == 0 &amp;&amp; i&lt; MAX) {<br />
          result = strcmp (all_names[loop].id,id);<br />
          loop++;<br />
          }<br />
          if (loop == MAX) {<br />
                   printf (&quot;Match not found&quot;);<br />
                   }<br />
          i = getchar();<br />
          }<br />
          <br />
int cust_add(void) {<br />
    printf(&quot;Enter the mew name\n&quot;);<br />
    gets(all_names[index].name);<br />
    <br />
    all_names[index].id = id;<br />
    index++;<br />
    id++;<br />
}<br />
<br />
<br />
        <br />
    <br />
CODE ENDS HERE.</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=9">C++  (Non Visual C++ Issues)</category>
			<dc:creator>thaathu</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488593</guid>
		</item>
		<item>
			<title>Case insensitive find() with std::string</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488592&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 18:49:21 GMT</pubDate>
			<description>I figured that the easiest way to do a case insensitive find() is probably to convert both the string and the text to be found to lower case. Is there an easy way to convert a std:: string to upper or lower case?</description>
			<content:encoded><![CDATA[<div>I figured that the easiest way to do a case insensitive find() is probably to convert both the string and the text to be found to lower case. Is there an easy way to convert a std:: string to upper or lower case?</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=9">C++  (Non Visual C++ Issues)</category>
			<dc:creator>John E</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488592</guid>
		</item>
		<item>
			<title>Help with array union and intersection</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488591&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 18:42:37 GMT</pubDate>
			<description><![CDATA[I am trying to write a program that reads in two arrays of integers representing the elements of two sets from two different user-specified input files and calculates both the union and the intersection of the two sets.  Use arrays to contain the input sets and build both the union and intersection. Both union and intersection must not contain duplicates. Here are the input files:

inputA. dat     0, 1, -3, 5, -11, 6, 8, 9, 11, 17, 15, 7, 4, 12

inputB. dat     0, -1, 3, 7, -6, 16, 5, 11, 12, 4, 21, 13

Here is what I have so far. Am I on the right track? Or not even close? Any help is appreciated, thank you.

#include <iostream>
#include <ifstream>
#include <string>
using namespace std;

int main() {
	int i(0), j(0), num, num2, arraya[i], arrayb[j];//declare and initialize variables
	string filename, filename1;

ifstream input ("inputA.dat");

	cout<<"Enter the name of the first input file"<<endl;//first input file from user
	cin>>filename;
	input.open(filename.c_str());

	if (input.fail()) {
	cerr<<"Could not open file";//if file cannot be opened
	exit(1);
	}

	input>>num;

	while(!input.eof()) {//read numbers from file

	arraya[i]=num;

	i++;

	input>>num;

	}

	cout<<"Array 1: "<<arraya[i]<<endl;//first array output

ifstream input1 ("inputB.dat");

	cout<<"Enter the name of the second input file"<<endl;//second input from user
	cin>>filename1;
	input1.open(filename1.c_str());

	if (input1.fail()) {
	cerr<<"Could not open file";//if file cannot be opened
	exit(1);
	}

	input1>>num2;

	while(!input1.eof()) {//read numbers from file

	arrayb[j]=num2;

	j++;

	input1>>num2;

	}

	cout<<"Array 2: "<<arrayb[j]<<endl;//second array output

for (int startindex=0; startindex<i; startindex++) {//step through each number of array
	int smallestindex=startindex;//smallest number

	for (int currentindex=startindex+1; currentindex<i; currentindex++) {//begin at startindex+1
		if(arraya[currentindex]<arraya[smallestindex])
		smallestindex=currentindex;//if new small number is found
		}

	swap(arraya[startindex], arraya[smallestindex]);//swap beginning and smallest numbers
	}

	cout<<"Sorted Array 1: "<<arraya[startindex]<<endl;//output sorted array

for (int startindex1=0; startindex1<j; startindex1++) {//step through each number of array
	int smallestindex1=startindex1;//smallest number

	for (int currentindex1=startindex1+1; currentindex1<j; currentindex1++) {//begin at startindex+1
		if(arrayb[currentindex1]<arrayb[smallestindex1])
		smallestindex1=currentindex1;//if new small number is found
		}

	swap(arrayb[startindex1], arrayb[smallestindex1]);//swap beginning and smallest numbers
	}

	cout<<"Sorted Array 2: "<<arrayb[startingindex1]<<endl;//output sorted array

//find union of arrays
int h(0), arrayu[];


for(int k=0; k<i; k++){

arrayu[h] = arraya[i];

h++;

}


for(int k=0; k<j; k++){

arrayu[h] = arrayb[j];

h++;

}

for (int startindex2=0; startindex2<h; startindex2++) {//step through each number of array
	int smallestindex2=startindex2;//smallest number

	for (int currentindex2=startindex2+1; currentindex2<h; currentindex2++) {//begin at startindex+1
		if(arrayu[currentindex2]<arrayu[smallestindex2])
		smallestindex2=currentindex2;//if new small number is found
		}

	swap(arrayu[startindex2], arrayu[smallestindex2]);//swap beginning and smallest numbers
	}


return 0;
}]]></description>
			<content:encoded><![CDATA[<div>I am trying to write a program that reads in two arrays of integers representing the elements of two sets from two different user-specified input files and calculates both the union and the intersection of the two sets.  Use arrays to contain the input sets and build both the union and intersection. Both union and intersection must not contain duplicates. Here are the input files:<br />
<br />
inputA. dat     0, 1, -3, 5, -11, 6, 8, 9, 11, 17, 15, 7, 4, 12<br />
<br />
inputB. dat     0, -1, 3, 7, -6, 16, 5, 11, 12, 4, 21, 13<br />
<br />
Here is what I have so far. Am I on the right track? Or not even close? Any help is appreciated, thank you.<br />
<br />
#include &lt;iostream&gt;<br />
#include &lt;ifstream&gt;<br />
#include &lt;string&gt;<br />
using namespace std;<br />
<br />
int main() {<br />
	int i(0), j(0), num, num2, arraya[i], arrayb[j];//declare and initialize variables<br />
	string filename, filename1;<br />
<br />
ifstream input (&quot;inputA.dat&quot;);<br />
<br />
	cout&lt;&lt;&quot;Enter the name of the first input file&quot;&lt;&lt;endl;//first input file from user<br />
	cin&gt;&gt;filename;<br />
	input.open(filename.c_str());<br />
<br />
	if (input.fail()) {<br />
	cerr&lt;&lt;&quot;Could not open file&quot;;//if file cannot be opened<br />
	exit(1);<br />
	}<br />
<br />
	input&gt;&gt;num;<br />
<br />
	while(!input.eof()) {//read numbers from file<br />
<br />
	arraya[i]=num;<br />
<br />
	i++;<br />
<br />
	input&gt;&gt;num;<br />
<br />
	}<br />
<br />
	cout&lt;&lt;&quot;Array 1: &quot;&lt;&lt;arraya[i]&lt;&lt;endl;//first array output<br />
<br />
ifstream input1 (&quot;inputB.dat&quot;);<br />
<br />
	cout&lt;&lt;&quot;Enter the name of the second input file&quot;&lt;&lt;endl;//second input from user<br />
	cin&gt;&gt;filename1;<br />
	input1.open(filename1.c_str());<br />
<br />
	if (input1.fail()) {<br />
	cerr&lt;&lt;&quot;Could not open file&quot;;//if file cannot be opened<br />
	exit(1);<br />
	}<br />
<br />
	input1&gt;&gt;num2;<br />
<br />
	while(!input1.eof()) {//read numbers from file<br />
<br />
	arrayb[j]=num2;<br />
<br />
	j++;<br />
<br />
	input1&gt;&gt;num2;<br />
<br />
	}<br />
<br />
	cout&lt;&lt;&quot;Array 2: &quot;&lt;&lt;arrayb[j]&lt;&lt;endl;//second array output<br />
<br />
for (int startindex=0; startindex&lt;i; startindex++) {//step through each number of array<br />
	int smallestindex=startindex;//smallest number<br />
<br />
	for (int currentindex=startindex+1; currentindex&lt;i; currentindex++) {//begin at startindex+1<br />
		if(arraya[currentindex]&lt;arraya[smallestindex])<br />
		smallestindex=currentindex;//if new small number is found<br />
		}<br />
<br />
	swap(arraya[startindex], arraya[smallestindex]);//swap beginning and smallest numbers<br />
	}<br />
<br />
	cout&lt;&lt;&quot;Sorted Array 1: &quot;&lt;&lt;arraya[startindex]&lt;&lt;endl;//output sorted array<br />
<br />
for (int startindex1=0; startindex1&lt;j; startindex1++) {//step through each number of array<br />
	int smallestindex1=startindex1;//smallest number<br />
<br />
	for (int currentindex1=startindex1+1; currentindex1&lt;j; currentindex1++) {//begin at startindex+1<br />
		if(arrayb[currentindex1]&lt;arrayb[smallestindex1])<br />
		smallestindex1=currentindex1;//if new small number is found<br />
		}<br />
<br />
	swap(arrayb[startindex1], arrayb[smallestindex1]);//swap beginning and smallest numbers<br />
	}<br />
<br />
	cout&lt;&lt;&quot;Sorted Array 2: &quot;&lt;&lt;arrayb[startingindex1]&lt;&lt;endl;//output sorted array<br />
<br />
//find union of arrays<br />
int h(0), arrayu[];<br />
<br />
<br />
for(int k=0; k&lt;i; k++){<br />
<br />
arrayu[h] = arraya[i];<br />
<br />
h++;<br />
<br />
}<br />
<br />
<br />
for(int k=0; k&lt;j; k++){<br />
<br />
arrayu[h] = arrayb[j];<br />
<br />
h++;<br />
<br />
}<br />
<br />
for (int startindex2=0; startindex2&lt;h; startindex2++) {//step through each number of array<br />
	int smallestindex2=startindex2;//smallest number<br />
<br />
	for (int currentindex2=startindex2+1; currentindex2&lt;h; currentindex2++) {//begin at startindex+1<br />
		if(arrayu[currentindex2]&lt;arrayu[smallestindex2])<br />
		smallestindex2=currentindex2;//if new small number is found<br />
		}<br />
<br />
	swap(arrayu[startindex2], arrayu[smallestindex2]);//swap beginning and smallest numbers<br />
	}<br />
<br />
<br />
return 0;<br />
}</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=9">C++  (Non Visual C++ Issues)</category>
			<dc:creator>tw02</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488591</guid>
		</item>
		<item>
			<title>Dynamic Parameters - some questions</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488590&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 17:59:03 GMT</pubDate>
			<description><![CDATA[Hi - I'm new to the forum, so please go easy on me.

These are straight Crystal XIR2 questions regarding dynamic parameters:

1) I am using a dynamic parameter to allow a user to select against an ID field, so I am using the 'Description' column (on the Edit Parameter dialog) to prompt the user with a friendly description rather than a code. This works fine. But then I am trying to put a text box / formula in the report header to display the filter criteria that have been applied. I can get the selected codes to be displayed, using the following (Basic syntax), where {Territories} is multi-select:

'Add the selected territories
for i = 1 to UBound({?Territories})
  If i = 1 then formula = formula & "Territories: "
  formula = formula & {?Territories}(i) & ", "
  If i = UBound({?Territories}) then formula = left(Formula, Len(Formula) - 2)  & chr(13) & chr(10)   'remove the final comma and add CRLF
Next

But I want to display the friendly text descriptions, not the codes - can this be done?

2) Where the user selects all fields (eg All territories, in the above example), I would like to insert something like

Territories: All

rather than 

Territores: (long list of all territories here)

Is there a way to test whether the run-time {Territories} parameter contains all of the possible values, so that this can be achieved? Or how do other people handle the 'SELECT ALL' requirement with dynamic parameters?

3) Handling NULLs / empty fields.
After building a dynamic parameter, the run-time parameter value list does not allow the option to select NULLs. So am I right in assuming that the best way to get round this problem is to code around NULLs using an appropriate Record Selection formula?

Thanks for any suggestions
Phil]]></description>
			<content:encoded><![CDATA[<div>Hi - I'm new to the forum, so please go easy on me.<br />
<br />
These are straight Crystal XIR2 questions regarding dynamic parameters:<br />
<br />
1) I am using a dynamic parameter to allow a user to select against an ID field, so I am using the 'Description' column (on the Edit Parameter dialog) to prompt the user with a friendly description rather than a code. This works fine. But then I am trying to put a text box / formula in the report header to display the filter criteria that have been applied. I can get the selected codes to be displayed, using the following (Basic syntax), where {Territories} is multi-select:<br />
<br />
'Add the selected territories<br />
for i = 1 to UBound({?Territories})<br />
  If i = 1 then formula = formula &amp; &quot;Territories: &quot;<br />
  formula = formula &amp; {?Territories}(i) &amp; &quot;, &quot;<br />
  If i = UBound({?Territories}) then formula = left(Formula, Len(Formula) - 2)  &amp; chr(13) &amp; chr(10)   'remove the final comma and add CRLF<br />
Next<br />
<br />
But I want to display the friendly text descriptions, not the codes - can this be done?<br />
<br />
2) Where the user selects all fields (eg All territories, in the above example), I would like to insert something like<br />
<br />
Territories: All<br />
<br />
rather than <br />
<br />
Territores: (long list of all territories here)<br />
<br />
Is there a way to test whether the run-time {Territories} parameter contains all of the possible values, so that this can be achieved? Or how do other people handle the 'SELECT ALL' requirement with dynamic parameters?<br />
<br />
3) Handling NULLs / empty fields.<br />
After building a dynamic parameter, the run-time parameter value list does not allow the option to select NULLs. So am I right in assuming that the best way to get round this problem is to code around NULLs using an appropriate Record Selection formula?<br />
<br />
Thanks for any suggestions<br />
Phil</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=64">Crystal Reports</category>
			<dc:creator>Wookiee</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488590</guid>
		</item>
		<item>
			<title>C++ and Python together (like in Battlefield 2)</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488589&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 17:37:33 GMT</pubDate>
			<description><![CDATA[Hi guys,

im currently working on a c++ project called GHost++ (http://www.codelain.com/forum/).
Therefore i want to make a plugin system like in battlefield 2.
It works this way:
1.) There are some triggers where you can code something to (e.g. EventPlayerJoined( CPotentialPlayer *potential, CIncomingJoinPlayer *joinPlayer ) ).
2.) Battlefield 2 executes a file called __init__.py
3.) __init__.py:

Code:
---------
import myModule
myModule.init()
---------
4.) myModule.py
[code]
import ghost

def init():
    ghost.registerEvent( EventPlayerJoined, 'MyPlayerJoinedFunction' )

MyPlayerJoinedFunction( potential, player ):
    if player.getName() == 'Krauzi': #GetName() is a c++ function which returns the players name
        print "Player Krauzi joined the game!"

So my question is:
how can i do it this way for my c++ project GHost++?
Ive read something about Boost, but i got some information that this is a) slow and b) memory intensive.
But if this is the most simple and useful way, i'll do it this way.

I dont have experience in boost but some basics in c++ and python. The boost tutorial was not as informative as i expected so im looking forward in YOU to help me (generally i dont want to code a new c++ hook for every event).

Hope some1 can help me
Cheers Krauzi]]></description>
			<content:encoded><![CDATA[<div>Hi guys,<br />
<br />
im currently working on a c++ project called GHost++ (<a rel="nofollow" href="http://www.codelain.com/forum/" target="_blank">http://www.codelain.com/forum/</a>).<br />
Therefore i want to make a plugin system like in battlefield 2.<br />
It works this way:<br />
1.) There are some triggers where you can code something to (e.g. EventPlayerJoined( CPotentialPlayer *potential, CIncomingJoinPlayer *joinPlayer ) ).<br />
2.) Battlefield 2 executes a file called __init__.py<br />
3.) __init__.py:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">import myModule<br />
myModule.init()</code><hr />
</div>4.) myModule.py<br />
[code]<br />
import ghost<br />
<br />
def init():<br />
    ghost.registerEvent( EventPlayerJoined, 'MyPlayerJoinedFunction' )<br />
<br />
MyPlayerJoinedFunction( potential, player ):<br />
    if player.getName() == 'Krauzi': #GetName() is a c++ function which returns the players name<br />
        print &quot;Player Krauzi joined the game!&quot;<br />
<br />
So my question is:<br />
how can i do it this way for my c++ project GHost++?<br />
Ive read something about Boost, but i got some information that this is a) slow and b) memory intensive.<br />
But if this is the most simple and useful way, i'll do it this way.<br />
<br />
I dont have experience in boost but some basics in c++ and python. The boost tutorial was not as informative as i expected so im looking forward in YOU to help me (generally i dont want to code a new c++ hook for every event).<br />
<br />
Hope some1 can help me<br />
Cheers Krauzi</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=9">C++  (Non Visual C++ Issues)</category>
			<dc:creator>Krauzi</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488589</guid>
		</item>
		<item>
			<title>Macro in Word 2007</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488588&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 17:28:14 GMT</pubDate>
			<description><![CDATA[Hi all and thanks for reading,

I am new at VB programming and am beating myself crazy on how to save a Word document using a user input in the document. Let me clarify, I have a document created with a macro that inserts the date, tracks it with a sequential number (using bookmarks with a text file) and saves it to our shared drive on the network (see below). I want the ability use the macro to save the document with a user input so to keep all documents organized. Maybe using their company ID or name. Any help would be greatly appreciated!

ActiveDocument.Bookmarks("Date").Range.InsertBefore Date

Order = System.PrivateProfileString("S:Sample.Txt", "MacroSettings", "Sample")

If Order = "" Then
    Order = 1
Else
    Order = Order + 1
End If

System.PrivateProfileString("S:\Sample.Txt", "MacroSettings", "Sample") = Order

ActiveDocument.Bookmarks("Sample").Range.InsertBefore Format(Order, "0000#")
ActiveDocument.SaveAs FileName:="S:\Sample " & Format(Order, "0000#")

End Sub]]></description>
			<content:encoded><![CDATA[<div>Hi all and thanks for reading,<br />
<br />
I am new at VB programming and am beating myself crazy on how to save a Word document using a user input in the document. Let me clarify, I have a document created with a macro that inserts the date, tracks it with a sequential number (using bookmarks with a text file) and saves it to our shared drive on the network (see below). I want the ability use the macro to save the document with a user input so to keep all documents organized. Maybe using their company ID or name. Any help would be greatly appreciated!<br />
<br />
ActiveDocument.Bookmarks(&quot;Date&quot;).Range.InsertBefore Date<br />
<br />
Order = System.PrivateProfileString(&quot;S:Sample.Txt&quot;, &quot;MacroSettings&quot;, &quot;Sample&quot;)<br />
<br />
If Order = &quot;&quot; Then<br />
    Order = 1<br />
Else<br />
    Order = Order + 1<br />
End If<br />
<br />
System.PrivateProfileString(&quot;S:\Sample.Txt&quot;, &quot;MacroSettings&quot;, &quot;Sample&quot;) = Order<br />
<br />
ActiveDocument.Bookmarks(&quot;Sample&quot;).Range.InsertBefore Format(Order, &quot;0000#&quot;)<br />
ActiveDocument.SaveAs FileName:=&quot;S:\Sample &quot; &amp; Format(Order, &quot;0000#&quot;)<br />
<br />
End Sub</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=4">Visual Basic 6.0 Programming</category>
			<dc:creator>enapoletano</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488588</guid>
		</item>
		<item>
			<title>The main disadvantage of C++ Object Model</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488587&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 17:23:59 GMT</pubDate>
			<description><![CDATA[Hello,

I've been reading the "Inside C++ Object Model" and when reach to the 1.1 section - "The C++ Object Model" I can't understand the content of author. That's as following:

<b>Stroustrup's original (and still prevailing) C++ Object Model is derived from the simple object model by optimizing for space and access time. Nonstatic data members are allocated directly within each class object. Static data members are stored outside the individual class object. Static and nonstatic function members are also hoisted outside the class object. Virtual functions are supported in two steps:

A table of pointers to virtual functions is generated for each class (this is called the virtual table).

A single pointer to the associated virtual table is inserted within each class object (traditionally, this has been called the vptr). The setting, resetting, and not setting of the vptr is handled automatically through code generated within each class constructor, destructor, and copy assignment operator (this is discussed in Chapter 5). The type_info object associated with each class in support of runtime type identification (RTTI) is also addressed within the virtual table, usually within the table's first slot.

Figure 1.3 illustrates the general C++ Object Model for our Point class. The primary strength of the C++ Object Model is its space and runtime efficiency. Its primary drawback is the need to recompile unmodified code that makes use of an object of a class for which there has been an addition, removal, or modification of the nonstatic class data members. (The two table model, for example, offers more flexibility by providing an additional level of indirection. But it does this at the cost of space and runtime efficiency.)</b>

He said the the main drawback is to recompile the unmodified code but I can imagine that situation. Anyone can give me several examples for that?

Thanks,
HTS]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I've been reading the &quot;Inside C++ Object Model&quot; and when reach to the 1.1 section - &quot;The C++ Object Model&quot; I can't understand the content of author. That's as following:<br />
<br />
&lt;b&gt;Stroustrup's original (and still prevailing) C++ Object Model is derived from the simple object model by optimizing for space and access time. Nonstatic data members are allocated directly within each class object. Static data members are stored outside the individual class object. Static and nonstatic function members are also hoisted outside the class object. Virtual functions are supported in two steps:<br />
<br />
A table of pointers to virtual functions is generated for each class (this is called the virtual table).<br />
<br />
A single pointer to the associated virtual table is inserted within each class object (traditionally, this has been called the vptr). The setting, resetting, and not setting of the vptr is handled automatically through code generated within each class constructor, destructor, and copy assignment operator (this is discussed in Chapter 5). The type_info object associated with each class in support of runtime type identification (RTTI) is also addressed within the virtual table, usually within the table's first slot.<br />
<br />
Figure 1.3 illustrates the general C++ Object Model for our Point class. The primary strength of the C++ Object Model is its space and runtime efficiency. Its primary drawback is the need to recompile unmodified code that makes use of an object of a class for which there has been an addition, removal, or modification of the nonstatic class data members. (The two table model, for example, offers more flexibility by providing an additional level of indirection. But it does this at the cost of space and runtime efficiency.)&lt;/b&gt;<br />
<br />
He said the the main drawback is to recompile the unmodified code but I can imagine that situation. Anyone can give me several examples for that?<br />
<br />
Thanks,<br />
HTS</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=9">C++  (Non Visual C++ Issues)</category>
			<dc:creator>hoangtuansu</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488587</guid>
		</item>
		<item>
			<title>friend functions giving me heartburn</title>
			<link>http://www.codeguru.com/forum/showthread.php?t=488586&amp;goto=newpost</link>
			<pubDate>Sat, 21 Nov 2009 17:19:35 GMT</pubDate>
			<description><![CDATA[Alright, I give up. What is wrong with this,

Matrix3.h

Code:
---------
namespace obrsp
{

namespace linalg
{

Vector3 operator* (const Vector3& rkPoint, const Matrix3& rkMatrix);
Matrix3 operator* (Real fScalar, const Matrix3& rkMatrix);

class Matrix3
{
       ....

protected:
	// vector * matrix [1x3 * 3x3 = 1x3]
	friend Vector3 operator* (const Vector3& rkVector, const Matrix3& rkMatrix);
       ....
	// scalar * matrix
	friend Matrix3 operator* (Real fScalar, const Matrix3& rkMatrix);

	Real m[3][3];
};

} // end namespace

} // end namespace
---------
Matrix3.cpp

Code:
---------
#include "Matrix3.h"

using namespace obrsp::linalg;

Vector3 operator* (const Vector3& rkPoint, const Matrix3& rkMatrix)
{
	Vector3 kProd;
	for (size_t iRow = 0; iRow < 3; iRow++)
	{
               // ERROR IN ACCESSING m[0][iRow]!!!!!!!!!!!!!!!!
		kProd[iRow] =
			rkPoint[0]*rkMatrix.m[0][iRow] +
			rkPoint[1]*rkMatrix.m[1][iRow] +
			rkPoint[2]*rkMatrix.m[2][iRow];
	}
	return kProd;
}

Matrix3 operator* (Real fScalar, const Matrix3& rkMatrix)
{
	Matrix3 kProd;
	for (size_t iRow = 0; iRow < 3; iRow++)
	{
               // ERROR IN ACCESSING m[0][iRow]!!!!!!!!!!!!!!!!
		for (size_t iCol = 0; iCol < 3; iCol++)
			kProd[iRow][iCol] = fScalar*rkMatrix.m[iRow][iCol];
	}
	return kProd;
}
---------
Generates the following compile error:

Code:
---------
/home/yamokosk/workspace/linalg/src/Matrix3.h: In function ‘obrsp::linalg::Vector3 operator*(const obrsp::linalg::Vector3&, const obrsp::linalg::Matrix3&)’:
/home/yamokosk/workspace/linalg/src/Matrix3.h:239: error: ‘obrsp::linalg::Real obrsp::linalg::Matrix3::m [3][3]’ is protected
/home/yamokosk/workspace/linalg/src/Matrix3.cpp:140: error: within this context
/home/yamokosk/workspace/linalg/src/Matrix3.h:239: error: ‘obrsp::linalg::Real obrsp::linalg::Matrix3::m [3][3]’ is protected
/home/yamokosk/workspace/linalg/src/Matrix3.cpp:141: error: within this context
/home/yamokosk/workspace/linalg/src/Matrix3.h:239: error: ‘obrsp::linalg::Real obrsp::linalg::Matrix3::m [3][3]’ is protected
/home/yamokosk/workspace/linalg/src/Matrix3.cpp:142: error: within this context
/home/yamokosk/workspace/linalg/src/Matrix3.h: In function ‘obrsp::linalg::Matrix3 operator*(obrsp::linalg::Real, const obrsp::linalg::Matrix3&)’:
/home/yamokosk/workspace/linalg/src/Matrix3.h:239: error: ‘obrsp::linalg::Real obrsp::linalg::Matrix3::m [3][3]’ is protected
/home/yamokosk/workspace/linalg/src/Matrix3.cpp:175: error: within this context
---------
What am I missing in my use of the friend functions??]]></description>
			<content:encoded><![CDATA[<div>Alright, I give up. What is wrong with this,<br />
<br />
Matrix3.h<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">namespace obrsp<br />
{<br />
<br />
namespace linalg<br />
{<br />
<br />
Vector3 operator* (const Vector3&amp; rkPoint, const Matrix3&amp; rkMatrix);<br />
Matrix3 operator* (Real fScalar, const Matrix3&amp; rkMatrix);<br />
<br />
class Matrix3<br />
{<br />
&nbsp; &nbsp; &nbsp;  ....<br />
<br />
protected:<br />
&nbsp; &nbsp; &nbsp; &nbsp; // vector * matrix [1x3 * 3x3 = 1x3]<br />
&nbsp; &nbsp; &nbsp; &nbsp; friend Vector3 operator* (const Vector3&amp; rkVector, const Matrix3&amp; rkMatrix);<br />
&nbsp; &nbsp; &nbsp;  ....<br />
&nbsp; &nbsp; &nbsp; &nbsp; // scalar * matrix<br />
&nbsp; &nbsp; &nbsp; &nbsp; friend Matrix3 operator* (Real fScalar, const Matrix3&amp; rkMatrix);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Real m[3][3];<br />
};<br />
<br />
} // end namespace<br />
<br />
} // end namespace</code><hr />
</div>Matrix3.cpp<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &quot;Matrix3.h&quot;<br />
<br />
using namespace obrsp::linalg;<br />
<br />
Vector3 operator* (const Vector3&amp; rkPoint, const Matrix3&amp; rkMatrix)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Vector3 kProd;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (size_t iRow = 0; iRow &lt; 3; iRow++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // ERROR IN ACCESSING m[0][iRow]!!!!!!!!!!!!!!!!<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kProd[iRow] =<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rkPoint[0]*rkMatrix.m[0][iRow] +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rkPoint[1]*rkMatrix.m[1][iRow] +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rkPoint[2]*rkMatrix.m[2][iRow];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return kProd;<br />
}<br />
<br />
Matrix3 operator* (Real fScalar, const Matrix3&amp; rkMatrix)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Matrix3 kProd;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (size_t iRow = 0; iRow &lt; 3; iRow++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // ERROR IN ACCESSING m[0][iRow]!!!!!!!!!!!!!!!!<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (size_t iCol = 0; iCol &lt; 3; iCol++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kProd[iRow][iCol] = fScalar*rkMatrix.m[iRow][iCol];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return kProd;<br />
}</code><hr />
</div>Generates the following compile error:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">/home/yamokosk/workspace/linalg/src/Matrix3.h: In function ‘obrsp::linalg::Vector3 operator*(const obrsp::linalg::Vector3&amp;, const obrsp::linalg::Matrix3&amp;)’:<br />
/home/yamokosk/workspace/linalg/src/Matrix3.h:239: error: ‘obrsp::linalg::Real obrsp::linalg::Matrix3::m [3][3]’ is protected<br />
/home/yamokosk/workspace/linalg/src/Matrix3.cpp:140: error: within this context<br />
/home/yamokosk/workspace/linalg/src/Matrix3.h:239: error: ‘obrsp::linalg::Real obrsp::linalg::Matrix3::m [3][3]’ is protected<br />
/home/yamokosk/workspace/linalg/src/Matrix3.cpp:141: error: within this context<br />
/home/yamokosk/workspace/linalg/src/Matrix3.h:239: error: ‘obrsp::linalg::Real obrsp::linalg::Matrix3::m [3][3]’ is protected<br />
/home/yamokosk/workspace/linalg/src/Matrix3.cpp:142: error: within this context<br />
/home/yamokosk/workspace/linalg/src/Matrix3.h: In function ‘obrsp::linalg::Matrix3 operator*(obrsp::linalg::Real, const obrsp::linalg::Matrix3&amp;)’:<br />
/home/yamokosk/workspace/linalg/src/Matrix3.h:239: error: ‘obrsp::linalg::Real obrsp::linalg::Matrix3::m [3][3]’ is protected<br />
/home/yamokosk/workspace/linalg/src/Matrix3.cpp:175: error: within this context</code><hr />
</div>What am I missing in my use of the friend functions??</div>

]]></content:encoded>
			<category domain="http://www.codeguru.com/forum/forumdisplay.php?f=9">C++  (Non Visual C++ Issues)</category>
			<dc:creator>yamokosk</dc:creator>
			<guid isPermaLink="true">http://www.codeguru.com/forum/showthread.php?t=488586</guid>
		</item>
	</channel>
</rss>
