|
I tried all your suggestions. But nothing worked.
The next thing I should suspect is some hardware instruction set bug!!
When I worked in Linux long time ago, I did not seem to encounter this problem!
Is there any way I can contact Micorsoft's personnel without having to purchase a subsciption.
I can't imagine programming without these constructs. But it is possible with virtual base classes containg the same data structure. Thus one ends up always using derived types when such a class is needed in a "cicular" way.
Ganesh
|
|
|
|
|
I made this little test program and it compiled and worked :
#include "stdafx.h"
class Point3D;
class Point2D
{
public:
int i, j;
Point2D() { Set( 0, 0 ); }
Point2D(int a, int b) { Set( a, b ); }
void Set( int a, int b ) { i = a; j = b; }
__inline void projectFrom(Point3D *p3d);
};
class Point3D
{
public:
int i, j, k;
Point3D() { Set( 0, 0, 0 ); }
Point3D(int a, int b, int c) { Set( a, b, c ); }
Point3D& operator=(const Point2D& p2d) { Set( p2d.i, p2d.j, 0 ); }
void Set(int a, int b, int c) { i = a; j = b; k = c; }
};
void Point2D::projectFrom(Point3D *p3d)
{
i = p3d->i;
j = p3d->j;
}
int main()
{
Point2D p2d(1,2);
Point3D p3d(2,3,4);
p2d.projectFrom( &p3d );
fprintf( stdout, "p2d = (%d, %d)\n", p2d.i, p2d.j );
return 0;
}
|
|
|
|
|
Rick York wrote:
void Point2D::projectFrom(Point3D *p3d)
... written below the class definition ;)
|
|
|
|
|
Hello CP Visitor.
You are right from the beginning. I misread the compiler remarks
as I put all function code in one line. Had I put those assigments on a
separate line, I would have at least undetstood that there is no
problem with forward referencing, but something else. I would have saved you all some time.
Thanks.
Ganesh
|
|
|
|
|
Hello 'Rick York'
Thanks for your time. Just before checking for messages,
I got it right finally. You are absolutely right. Since I put all
the code in one line, I could not decipher compiler message clearly.
Had I put the assignment code
<br />
{i = p3d.i; j = p3d.j; }
on a different line, I would have saved myself and all of you so much time.
My apologies.
Ganesh
Ganesh
|
|
|
|
|
Hello All,
I finally I uderstood the issue. Thanks everybody.
Ganesh
|
|
|
|
|
i used FindFirstChangeNotification()FindFirstChangeNotification()AND WaitForSingleObject() to notify any change in a mentioned directory.its working.But i want to mention the cause of notification (say its due to deletion of a file).i declared every filter condition in FindFirstChangeNotification()
|
|
|
|
|
|
this the code....
DWORD change= WaitForSingleObject(hr,INFINITE);
if(change==WAIT_OBJECT_0)
::AfxMessageBox("CHANGE HAS BEEN DETECTED");
FindCloseChangeNotification(hr);
in the ::AfxMessageBox() I WANT TO MENTION THE REASON FOR NOTIFICATION ie DUE TO FILE DELETION OR FILE RENAME ETC
|
|
|
|
|
|
|
How to convert a LONGLONG data type to binary ?
Thanks for any help.
|
|
|
|
|
I guess you mean convert to a binary string... right? If you can't find a runtime library function to do it, try something like this:
LONGLONG value = 12345;
TCHAR mystring[sizeof(LONGLONG)*8 + 1];
for(int i = 0; i < sizeof(LONGLONG)*8; i++)
mystring[i] = ((value >> (sizeof(LONGLONG)*8 - i - 1)) & 1) ? _T('1') : _T('0');
mystring[sizeof(LONGLONG)*8] = 0; Hope that helps.
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Thank you.
I tried to put the answer to the code you gave me in a message box like that:
void CMyBitsDlg::ConvertLLtoBin()
{ LONGLONG value = 12345;
TCHAR mystring[sizeof(LONGLONG)];
for(int i = 0; i < sizeof(LONGLONG); i++)
mystring[i] = ((value >> (sizeof(LONGLONG) - i - 1)) & 1) ? _T('1') : _T('0');
AfxMessageBox(mystring);
}
The answer is 00111001P@
Any idea about the error?
|
|
|
|
|
you forgot to end your string with
mystring[i] = '\0'; that doesn't happend with my CString (see here[^])
of course, int i; should be declared before for() loop...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Yes the thought just popped into my mind, and I just returned now to correct my mistake.
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
datas are written in binary format in memory...
however, if you like to print an integer in binary format, this link[^] should help.
here is the sample :
<font color=#0000FF>LONGLONG</font> iVal = 125932; <font color=#008000>
CString strVal = <font color=#808080>""</font>; <font color=#008000>
<font color=#0000FF>for</font> (<font color=#0000FF>int</font> i = 0; i < <font color=#0000FF>sizeof</font>(LONGLONG); i++) {
strVal.Insert(0, ((iVal & 0x00000001) ? <font color=#808080>"1"</font> : <font color=#808080>"0"</font>));
iVal >>= 1;
}
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thank you.
Pls read my reply to Joel Holdsworth.
|
|
|
|
|
fardak wrote:
Pls read my reply to Joel Holdsworth
hey, already done...
you define mystring as a TCHAR[], which need a trailing '\0' to be displayed correctly...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thanks again.
I rewrote this:
void CMyBitsDlg::ConvertLLtoBin()
{ LONGLONG value = 12345;
TCHAR mystring[sizeof(LONGLONG)];
for(int i = 0; i < sizeof(LONGLONG); i++)
mystring[i] = ((value >> (sizeof(LONGLONG) - i - 1)) & 1) ? _T('1') : _T('0');
mystring[i]='\0'; //added
AfxMessageBox(mystring);
}
And the answer is 00111001 which is 39 hexadecimal.
So something is wrong.
But the strange thing happening now is that I have an error memory reading message.
|
|
|
|
|
Almost correct. You need to change
TCHAR mystring[sizeof(LONGLONG)]; to
TCHAR mystring[sizeof(LONGLONG) + 1]; and instead of writing
mystring[i]='\0'; try
mystring[sizeof(LONGLONG)] = 0; I think that might help
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Thanks again.
Ok the last version is
void CMyBitsDlg::ConvertLLtoBin()
{ //LONGLONG value = 12345;
LONGLONG value = 0xFF FF FF FF FF FF FF FF;
TCHAR mystring[sizeof(LONGLONG)+1];
for(int i = 0; i < sizeof(LONGLONG); i++)
mystring[i] = ((value >> (sizeof(LONGLONG) - i - 1)) & 1) ? _T('1') : _T('0');
mystring[sizeof(LONGLONG)]='\0';
AfxMessageBox(mystring);
}
And the answer is 11 11 11 11
Instead od a 64 times '1'.
Where the rest has gone ?
|
|
|
|
|
|
Thank you for yor time and effort.
I tried you edited code with a value of
0xFF FF FF FF FF FF FF FF (//16 F)
and it gives 64 1's which is the correct answer .
Thanks again.
|
|
|
|
|