|
Than I would suggest you have a specific method that both constructors call to initialize your data.
Read this:
http://www.brpreiss.com/books/opus4/html/page599.html[^]
What might be happening is that the custom constructor inits the variables but when the body of the default constructor runs those variables are set to system define defaults (i.e. random noise). I could well be wrong about this, but calling a constructor from within your default constructor seems a little cheesy to me.
|
|
|
|
|
Please take into account that calling a constructor inside another constructor is just illegal C++. The fact that it seems to work is just mere luck. C++ does not allow to do this. (Incidentally, this feature is being discussed for inclusion into the next revision of the C++ standard, under the name forward constructor.)
A valid alternative, however, is the following, which uses the so-called placement new:
#include <new>
...
CTransfer::CTransfer()
{
new (this) CTransfer(new CTransferFileInfo, NULL);
} All in all, having a common initialization function, as has been suggested, is probably clearer. Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Joaquín M López Muñoz wrote:
Please take into account that calling a constructor inside another constructor is just illegal C++.
Calling a base class constructor from a derived class constructor, would that be illigal to, or do you have to call them like this:
<br />
ClassB : public ClassA<br />
{
};<br />
<br />
ClassB::ClassB() : ClassA(), SomeMemberClass1(), SomeMemberClass2()<br />
{<br />
}<br />
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
You have to call the constructors on the initializaer list:
ClassB::ClassB() : ClassA(), SomeMemberClass1(), SomeMemberClass2()
{
}
ClassB::ClassB()
{
ClassA::ClassA();
SomeMemberClass1::SomeMemberClass1();
SomeMemberClass1::SomeMemberClass2();
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Thanks,
I guess that I've got some classes to re-write...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
|
Does anyone know if it is possible to subclass the list header for an IShellView so that it can be custom drawn. This is easy with an MFC list control, but I have not been able to find a way to do this with the IShellView. I like the built in features of the IShellView, but would like to custom draw the list headers to match the rest of my program.
Thanks,
Nick
|
|
|
|
|
Currently I have a string [zPart] which would look something like the following “*(-2)”
I need to isolate everything inside the brackets “( …)” so it can be used later (in this case the –2).
My main goal is to replace * by an integer and perform the arithmetic inside the “(…)” on it. This will generate my finale value.
Any clues on how this could be implemented?
|
|
|
|
|
The answer depends largely on what compiler you are using.
If you are stuck using ansi-C there is a well known set of functions that are used for such string parseing needs. Look here[^]
MFC,.NET etc, generally provide similar functionality as part of their framework.
|
|
|
|
|
is this[^] help ?
TOXCCT >>> GEII power
|
|
|
|
|
Currently I have a string [zPart] which is either “*” or an integer value.
To differentiate between the two I do the following:
if (zPart == "*")
do something
else
do something else
This works great for now however I want to expand the functionality by allowing [zPart] to be something other then just “*”, for example “*(-2)”.
So I need a way to say the following [pseudo-code]:
if (zPart has a “*” in it)
do something
else
do something else
How would one implement this in C++?
Thanks,
|
|
|
|
|
|
Im new to C++ so sorry for this braindead question but (probably because its so basic) I cant find a solution to it. I have a Win32 app and I would like it to fill up the entire screen without a title bar. Is there something I can do when I call the CreateWindow function to make my app do this? If not how would I go about this?
Thanks!
|
|
|
|
|
|
Hello,
I just got a rude awakening when creating an app in my new VB.net IDE: anything created there requires that the end user download and install the ENTIRE .net framework! This wasn't the case in my VB 6.0.
So, does this also apply to VC++.net? Will VC++.net allow me to statically link the libraries so that I don't kill my users with a burdoning installation?
thanks,
JennyP
|
|
|
|
|
C++ is the only language that the .NET compiler can natively compile. That is to say, unless you use managed C++ ( and why would you ? ), there's no need ( and indeed no use ) in installing the .NET framework on a client machine.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Do someone have some message flow (something like PostMessage with WM_CHAR) to simulate copy/paste (CTRL-C CTRL-V) within an application ?
tx anyway
GuimaSun
www.nexsun.com.br
NEXSUN TechZone
|
|
|
|
|
Are you talking about the WM_COPY and WM_PASTE messages?
"Opinions are neither right nor wrong. I cannot change the opinion you have of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
David, the problem with these messages is it just works in a edit control or combo box or some control that treats them, so AFAIK I have to simulate CTRL-C/CTRL-V which works with any situation
Thanks anyway.
|
|
|
|
|
What type of control are you trying to copy from or paste to?
Anonymous wrote:
...I have to simulate CTRL-C/CTRL-V which works with any situation
You could always use SendMessage(WM_CHAR, ...) to send the Ctrl+C and Ctrl+V keys.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have a system wide DLL Hook which filter keypressing to a serie of personal functions, one desired would be copy/paste...so it must work whitin any context, a selection made on a textbox, on a web page, etc.
I agree the way is SendMessage(WM_CHAR, ...) thats the point I have to research the entire message flow, but for sure someone already did it before
Thanks again
GuimaSun
www.nexsun.com.br
NEXSUN TechZone
|
|
|
|
|
I am using the IE Web browser control to load and display some html pages that are resources in my program.
I notice that if I load a page that has a "link" tag specifying a style sheet the first time then I can properly enumerate through the document's DOM and get at various items. *But* if I load it again, then suddenly the DOM only contains the HTML, HEAD, TITLE, and LINK tags.
However if I remove/comment out the LINK tag then everything is fine! Argggg!!
Anyone have any suggestions how to work around this?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Dear friends,
I want to associate a menu to a dialog. So i created a simple dialog appliation. In resource editor, i created a menu item "&File" . Thus, in resource editor the letter "F" in "File" becomes underlined.
In OnCreate(), i used LoadMenu() and SetMenu() to associate menu with the dialog.
So far so good. But when i run my application, the menu appears on the dialog, but the "hot key character" is not underlined. When i press "Alt" key, it suddenly becomes underlined. Can anyone tell me why the hot key characted is not underlined by default as in other windows applications ??
Imtiaz
|
|
|
|
|
Hiding the underlines is a fairly standard Windows feature - I'm running Win2K here, and the IE browser window I'm currently typing in has no underlines until the Alt key is pressed - there's probably some underlying option you can change in your application, but why would you want to?
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
I'm currently working on implementing a namespace extension. The information I store in the PIDLs that I'm using comes from a database that has entries for every file and folder I want to be displayed inside of the extension. Currently I have my extension displayed on the desktop and all of the correct entries, along with my custom display information, are shown in the explorer. What I am having trouble with is implementing the Open and Save As dialog boxes to use my folder and its contents.
Problem #1: My extension displays in the Open dialog selection box for every program, but when I click on it I get a list of the folders it contains and no way to browse to the items that the folder contains. I believe that I have the correct flags set for these folders and files (SFGAO_FILESYSTEM, SFGAO_FILESYSANCESTOR, SFGAO_BROWSEABLE).
Problem #2: The files that I link to via my extension are encrypted files that need to be decrypted and saved to some sort of temp file so that the user can open them in various programs. I only want to decrypt these items when the user clicks Open in the dialog box. The file should then be decrypted to the file type that was selected in the Open dialog box (if it is a file type that is supported by the encrypted file).
I'm starting to think there is a possibility that I have not implemented an interface that I should have, but I am unsure of which interface that I need to implement. Currently I have implemented IClassFactory, IContextMenu, IEnumIDList, IExtractIcon, IShellFolder, IPersistFolder, IShellView and IOleCommandTarget.
Any information about how to implement the Open and Save As dialog boxes with namespace extensions would be appreciated.
|
|
|
|