|
I guess that the sentence CTransfer::CTransfer(new CTransferFileInfo(), NULL) is actually creating another instance of CTransfer... and of course, after leaving the method, the destructor is called... I guess I'd have to write much code anyway...
|
|
|
|
|
What happens when you just do this...
CTransfer::CTransfer()
{
m_pFileInfo = new CTransferFileInfo();
m_pConfig = NULL;
}
rather than this silliness...
CTransfer::CTransfer()
{
CTransfer::CTransfer(new CTransferFileInfo, NULL);
}
|
|
|
|
|
That "silliness" you call saves me a lot of coding. The contructor has too much initialization code. Actually, it is working, but i really don't want to code that much (because this problems is going on in other classes, also with too much initialization code).
Greetings.
|
|
|
|
|
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
|
|
|
|