|
Yes, because in that case an integer is fully defined (you know its size and everything). In your case, if Class_A is declared before Class_B in the file and if it contains a Class_B has member, this Class_B has not been fully defined yet, so it is impossible for the compiler to create the Class_A.
Think of it as my example: try to put a box 1 inside another box 2 and then box 2 inside box 1. This is the same problem here. In the example with your integer, you simply put box 1 (the integer) into box 2 (your class) but your integer doesn't contain your class.
Another example: if you declared Class_A before Class_B in your example and if Class_A does't contain Class_B, then it would be ok:
Class_A
{
public:
Class_A();
~Class_A();
int Test;
};
Class_B
{
public:
Class_B();
~Class_B();
Class_A AnotherTest;
};
This will work because Class_A is fully defined when you use it in Class_B. Now, if you want to use Class_B inside Class_A you cannot do that directly (there is noway you can fully define both classes if they contain each other). The workaround is to use a pointer inside to Class_B inside Class_A: A pointer is always 'known' (its size is always 4 bytes). And you need to use forward declaration of Class_B (it is more or less the same as function prototype but for classes):
class Class_B;
Class_A
{
public:
Class_A();
~Class_A();
int Test;
Class_B* pB;
};
Class_B
{
public:
Class_B();
~Class_B();
Class_A AnotherTest;
};
Is it clearer now ?
|
|
|
|
|
Cedric, I fully unstand the trick now.
Thank you very much.
|
|
|
|
|
thank you Steve.
I forgot to say I am using MFC (visual C++ 6.0). In visual C++, a new class is implemented by a pair of files , *.h and *.cpp("Insert" | "Class" ....). Is it possible to mix two or more classes into one single file? Is it possible to merge two *.h files for two separate classes into single file and do the same thing with the corresponding *.cpp files?
-- modified at 18:34 Tuesday 7th November, 2006
|
|
|
|
|
Hi friends
I developed a an address book program using CListCtrl. Contents of address book is more than 15000 entries. It causes slow while using address book. How can i solve this problem ? Kindly help me.
Thanks in advance
Regards
KK
KK
|
|
|
|
|
Dont retrieve all addresses at one call only. Instead, Fill list control with number of empty rows equal to no. of records in address book. And then retrieve only records for rows visible in list control. Keep on retriving records on scrolling.
You can check if for this row records has been set to avoid multilpe calls.
|
|
|
|
|
|
How do you insert your items to listctrl?
|
|
|
|
|
If there isn't any frame in a html document,'elementFromPoint' would
work fine,but when the element is in a frame,'elementFromPoint' can not get it.
How can I get it in a frame?
Thanks!
3.141592653... Never Stop
|
|
|
|
|
I have to place many check box on a Tab Page ,
but the checkbox have no caption ,
When the user want to slect any check box by
using the Tab switch on the keyboard. The checkbox
is not highlighted as it has no caption and He is
not able to identify the check box is currently slected
Can any one tell he some method trough which ,a higlight
or say a colour change can be done to the check box.
Remember we are not using the mouse (only keyboard)
thanks in advance
-- modified at 0:45 Tuesday 7th November, 2006
Vikas Amin
EATON
PUNE
|
|
|
|
|
Why they dont have caption?
|
|
|
|
|
I have lots of check box to be placed
on a small property sheet ,
more over grooping is possible so insted
of individual name groups have been created
Vikas Amin
EATON
PUNE
|
|
|
|
|
First I have a suggestion if you dont have caption on checkboxs use of tooltip for them.For color my naswer is OwnerDraw I think you can find an example on codeproject for ownerdraw its three led (checkboxs).
|
|
|
|
|
Owner-drawing the checkbox would probably be the way to go. There are plenty of articles on codeproject to guide you in owner-drawing controls.
I never thought of the fact that the focus indication is missing when omitting the label. Interesting.
|
|
|
|
|
..coming to think of it, you could do your own bookkeeping of the focus in your dialog, and just draw the focus indication from your dialog class.
|
|
|
|
|
I just have a dreadful feeling that your UI is going to suck.
Can you suggest a list control with the checkbox style, so all your items will fit on the window AND they can have labels?
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
I am using this code to insert data in msaccess database,but rateher then saving the record it will save in database some otehr values:
like:
ID DateTimeStamp MarketNo Bid MarketName Ask MarketState
-858993459 0:00:00 0 -368934881474191.0324 -368934881474191.0324 -13108
-858993458 0:00:00 1342 -368934881474191.0324 -368934881474191.0324 -13108
-858993457 0:00:00 1342 -368934881474191.0324 -368934881474191.0324 -13108
-858993456 0:00:00 1342 -368934881474191.0324 -368934881474191.0324 -13108
-858993455 0:00:00 1342 -368934881474191.0324 -368934881474191.0324 -13108
How to solve this problem,I have made comment line before the database code by which i am getting this problem.
<br />
void CArielProjectVer2Dlg::OnPriceChangeArielapictrl1(LPCTSTR SessionId, LPCTSTR RequestId, short MarketNo, LPCTSTR Market,<br />
LPCTSTR Bid, short BidDirection, LPCTSTR Ask, short AskDirection, <br />
LPCTSTR High, LPCTSTR Low, short MarketState, LPCTSTR Timestamp) <br />
{<br />
SessID=SessionId;<br />
CurrentRequestId=RequestId;<br />
CString MarketSt,a,b,c,d;<br />
<br />
txtMarket = Market;<br />
<br />
a.Format("%d",MarketNo);<br />
b.Format("%c",BidDirection);<br />
c.Format("%c",AskDirection);<br />
d.Format("%d",MarketState);<br />
<br />
m_MainEdit=m_MainEdit + "<Price Change>" +" " + SessionId + "\t" + RequestId +"\t"+ a ; <br />
m_MainEdit=m_MainEdit + "\t"+ Market + "\t " + Bid + "\t " + b + " \t"+ Ask + "\t" +c +"\t "+ High + "\t";<br />
m_MainEdit=m_MainEdit + Low + "\t" + d + " "+ "\t" + Timestamp + "\r\n";<br />
<br />
UpdateData(FALSE);<br />
iLineCount=m_EditCtrl.GetLineCount();<br />
m_EditCtrl.LineScroll(iLineCount);<br />
<br />
<br />
m_TQuote.MoveLast();<br />
int nCount = m_TQuote.m_ID;<br />
nCount++;<br />
<br />
m_TQuote.m_ID = nCount;<br />
<br />
HRESULT hResult = m_TQuote.Insert();
if(FAILED(hResult))<br />
{<br />
AfxMessageBox(_T("Error inserting the record"));<br />
return;<br />
}<br />
-- modified at 22:44 Monday 6th November, 2006
|
|
|
|
|
Hi,
could any body help, i want several techniques to hide a string from
debugging for example i need to hide lpszString_Tag from memory
LPCSTR lpszString_Tag = "CODEPROJECT";
...
MessageBox(lpzTitle,lpszString_Tag,MB_OK);
...
thanks
---
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
John von Neumann
|
|
|
|
|
I assume you want to obfuscate the string so that it's not visible when greping through the binary for strings? You can always use XOR.
#define XOR_KEY "%¤#\"¤%!¤12323%%3kjlkjlkl5j312l4j3#¤\"!\"#"
int main(int ac, char** av) {
LPCSTR szKey = XOR_KEY;
int k = 0;
int s = 0;
printf("int len = %d;\n", strlen(av[0]));
printf("char str[] = { ");
while(av[0][s]) {
printf("%d", av[0][s] ^ *szKey++);
if(!*szKey)
szKey = XOR_KEY;
}
printf("};\n");
} This small app will from the first given program argument, generate an encoded char array, and a length variable containing the length of the array. The output may for example be:
int len = 6;
char str[] = { 5, 122, 53, 21, 45, 139 }; In your app, include common.h, and put those variable declarations somewhere in your .cpp file. Then when you want to use the string, decode it using the XOR key again.
#include "common.h"
int len = 6;
char str[] = { 5, 122, 53, 21, 45, 139 };
...
LPCSTR newstr = new char[len + 1];
LPCSTR szKey = XOR_KEY;
for(int i = 0; i < len; ++i) {
newstr[i] = str[i] ^ *szKey++;
if(!*szKey)
szKey = XOR_KEY;
}
newstr[len] = 0;
At the end of this code, newstr will contain the string you passed as argument to the encoding application.
This encoding scheme works on the premise that: Charenc != Charorig ^ Key, and that Charorig = Charorig ^ Key ^ Key.
It won't help you against skilled crackers, but it will be a simple way to hide strings which you do not want to reveal for the casual "grepper".
--
Based on a True Story
|
|
|
|
|
I use CXR[^]. I have the encrypting as part of my Release mode build rules and it's a snap.
|
|
|
|
|
Thanks for help guys , I wished that these tips will be unknown by all crackers (Obviously for me ) , well ..this topic is opened and any other tricks will be welcome ...
---
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
John von Neumann
|
|
|
|
|
Hello all,
I am writing a server application that uses CAsyncSocket to send data to a client application which also uses CAsyncSocket to receive the data. The behavior that I am seeing is...
-Server listens and accepts client connection (no issue here)
-Server sends some data to the client.
-Client gets OnReceive message then receives data (sometimes).
All is well except the client does not always get the data that is sent by the server.
If the client and server are both running on the same machine, no data is lost. However, if the server is running on one machine and the client on another, about every third send is not received by the client.
Also, the server is not receiving an OnSend message. It is my understanding from another post that the server should receive an OnSend message after sending to indicate it is ready for another send.
I appreciate any help I can get on these issues. Thanks in advance!
~Rebecca
|
|
|
|
|
realius222 wrote: Also, the server is not receiving an OnSend message. It is my understanding from another post that the server should receive an OnSend message after sending to indicate it is ready for another send.
You'll need to call AsyncSelect(FD_WRITE) on the socket for OnSend() to be called by the
framework. You would do this on the socket accepted with Accept(). You may want to use other
flags as well but you at least need FD_WRITE to get OnSend() notification.
realius222 wrote: All is well except the client does not always get the data that is sent by the server.
With TCP, you need to repeatedly call Receive() (or recv()) on the socket until you get the
number of bytes you are expecting. There's no guarantee that a successful call to Receive() will
return more than one byte. Of course, it usually does.
For example, if, in your OnReceive() handler, you call Receive() to receive 100 bytes and
Receive() returns 50, then you can return from OnReceive() and call Receive() again in the next
OnReceive() call for the remaining 50 bytes. Therefore, you'll need to keep track of how much
you've received and/or how much you are still waiting to receive until you've received what you're
expecting.
Hope that made sense
Mark
|
|
|
|
|
realius222 wrote: Also, the server is not receiving an OnSend message. It is my understanding from another post that the server should receive an OnSend message after sending to indicate it is ready for another send.
Meaning of OnSend notification is different. The OnSend comes once both after establishing a connection or when WSAAsyncSelect(,,,FD_WRITE) called, which signifies a socket is ready for sending operation. The status “readiness for writing” remains until buffer space becomes available and a send fails with WSAEWOULDBLOCK. When buffer becomes available Windows Sockets notifies an application again. In other words, an application can assume that sends are possible starting from the first OnSend Notification and lasting until a send returns WSAEWOULDBLOCK. Therefore, it’s possible application receive OnSend only once after connecting and may send data via socket any time, in case an outgoing data flow rate less then a network capability.
Regars,
ISerik
|
|
|
|
|
Using VC++ 2005 Pro, I created the shell of an MFC ActiveX control, then added one property with get/put methods. That compiled ok.
Then I wrote a simple MFC dialog application to test my ActiveX control. Added the control, and gave it a variable name. That all worked ok after some studying about how to accomplish that.
My question is, the *.cpp and *.h files that were added to the MFC project do not contain the set/put methods of the control All those two files contain are the controls constructors. VC++ 6.0 compiler would put all the control's properties and methods in those to files for me. So, with VC++ 2005 how am I supposed to call the property and methods ? The control has a type library, but I don't know how to use it. Will someone please point me to a thread of site that shows how to use ActiveX with this compiler?
Thanks.
[edit]I found out how to create an MFC clas based on the type library, but how to use it in a CDialog application? It should not be this difficult. [/edit]
|
|
|
|
|
Hi,
I am writing a dll exporting an funcion to send email. Now I got a problem. When my dll was called by another application, the groupwise login dialog will show up, when I click 'Cancel', that login dialog will be gone. However, when my dll was called again, this login dialog won't show up anymore and MAPILogon return SUCCESS_SUCCESS, lhSession is not null. I don't know what's wrong. Can any one tell?
Thanks in advance.
|
|
|
|
|