|
About the OO safe question
i will use it like:
class MYCLASS
{
...
...
public:
KEY k; or KEY *k;
...
};
|
|
|
|
|
Hmm, that's not very OO. Google up some terms like 'data hiding' and 'design by contract' to get ideas on 'better' ways.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Sorry! If KEY is a private member?
Or what if i do it like
class MYCLASS
{
...
...
public:
void Get(KEY *k);
...
};
// in cpp
void MYCLASS::Get(Key *k)
{
// Do operation:
}
int main()
{
MYCLASS g;
KEY k; // key is empty
g.Get(&k);
//key is filled
// Do operations with k
return 0;
}
|
|
|
|
|
Yep, you can do it that way. It's not really the usual way to do things but you can do it that way if you wish. It would be more normal to write the functions that do operations with k as members of MYCLASS which use the private member k to do their work and return results to their callers e.g. Key validity.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
What is the difference to use it as KEY k; and KEY *k;
I have read some papers that say that there is speed difference or some kind of difference in memory.
(if i remember well)
Or what is the difference anyway?
|
|
|
|
|
If you're unsure of the difference between KEY k; an instance of KEY called k and KEY* k; an instance, called k, of a pointer to a KEY, then you really shouldn't be attempting any serious development in C++. Seriously I'm not being rude you need to read some books, go on a course or whatever or things will get very painful very quickly. C++ is not like BASIC or even VB. You can't really learn it from scratch by trial and error, you have to start from a certain base in order to stand a chance. At the very least read some Web tutorials on pointers before diving in or both the contents of your PC and your sanity are at risk.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Maybe i didn't ask right the question.
I know the difference between KEY k; and KEY *k; but i really care that the fact *k is allocated in free memory has some advantages?
|
|
|
|
|
OK but if you use a member instance
<br />
class CMyClass<br />
{<br />
private:<br />
KEY k; <br />
};<br />
then k is allocated wherever the instance of your class is allocated. You can use
heap
<br />
CMyClass* pMyInstance = new CMyClass();<br />
or stack
<br />
CMyClass MyInstance;<br />
If you're allocating really large amounts of data you definitely need the heap, possibly even look into the Virtual Memory API. In general its often best to leave the decision on where to allocate data up to the code that uses the data rather than trying to make it part of the data.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Putting a * there means that it is a pointer to a KEY structure, whereas no * means that it is actually a KEY structure and the required memory to hold all the KEY data is set aside for it.
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
Do you mean is it safe to define a structure within a structure?
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
Watch out for memory alignment issues if you are going to use these keys (I'm assume they will be crypto keys) with raw memory access. You can change the way the object is laid out in memory with the #pragma pack directive. It may not be a problem though, depends on how you'll use your struct (Actually it would show not so great design if you'd need this, but there may be performance reasons).
|
|
|
|
|
helle everyone...
i need help. how to create mfc aplication installer...
i mean i want to make my program to be software installer
please help me...thanks
thanks
|
|
|
|
|
why don't you use an existing installer like InnoSetup, NSIS, InstallShield, etc...?
|
|
|
|
|
thx, but i want to improve my question...
how to make application installer from mfc and opengl.
because i use opengl on my mfc....
|
|
|
|
|
Microsoft have published a set of "lovely" documentation on MSDN to accommodate for setup apps; it's called - rather daringly - the "Setup API" - take a look here.
Hope this helps,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
Install Shield is the one which I use but many alternative exist .
Vikas Amin
UNITED STATES STEEL CORPORATION
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
Hi all,
I am facing a strang problem for ImpersonateLoggedOnUser() on Vista 64.
I am having a service and it internally launches a dll and that dll impersonates to paricular domain user. The code works perfect on XP, 2k3, vista 32, XP 64. But on vista 64 the service crashes.
Does anybody have any idea why it might be creashing?
Even i am not able to remote debug it. For remote debugging i put a message box in the dll whenever it pops up i remotely attach to that process and click on the message box for debugging. But on vista i cant see any message box. So how should i remote debug the code on vista 64?
|
|
|
|
|
Hi All
How can i get removable drive letter in MFCvc++2005? Plz give some tips..
|
|
|
|
|
You can use GetLogicalDriveStrings() to get a list of availible drives (documentation here), then for each one use GetDriveType() (documentation here) to determine whether it is a removable drive or not.
Hope this helps,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
|
Hi all,
Is this possible to disable CEdit context menu ?
please tell me ?
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Derive a your class from CEdit and handle right button click.
Hope it helps.
Regards,
Sandip.
|
|
|
|
|
Yes, you can do that.
Derive your class from CEdit, and handle the WM_CONTEXTMENU message.
See this[^] MSDN page about WM_CONTEXTMENU.
If you only handle the right mouse message as another posted recommended, your user will still be able to get the context menu via the keyboard.
- Dy
|
|
|
|
|
Thanks For the info..
Regards,
Sandip.
|
|
|
|
|
Hi all,
i want to disable the restore button of any application which is show at thr right corner of application with Minimize and Close button.
if there is no option for disable it,than please tell me how can i stop to restore my application.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|