|
hi, all. I got 4 warnings when build the application like this
"warning C4520: 'CRptLog' : multiple default constructors specified", when I tried to debug the code, got some assertion failed, because for somereason, they only want certain value for some calltype.....then I found the application has memory leak:
Warning: skipping non-radio button in group.
The thread 0x874 has exited with code 0 (0x0).
Detected memory leaks!
Dumping objects ->
{1439} normal block at 0x0146D6B8, 2804 bytes long.
Data: < v w > 0A 00 00 00 08 F9 76 00 E0 77 17 00 00 00 00 00
{1438} normal block at 0x01450FA8, 18 bytes long.
Data: <data\download.db> 44 61 74 61 5C 44 6F 77 6E 6C 6F 61 64 2E 64 62
could anyone tell me is it because of the warning C4520 or the assertion failed causing memory leak?
the release works just fine.....appreciate any info.
|
|
|
|
|
valerie99 wrote:
warning C4520: 'CRptLog' : multiple default constructors specified",
Probably you have a default constructor ( CRptLog() ) and one that takes arguments and has default values ( i.e. CRptLog(int itemCount = 0) ). Now, if you call a constructor and don't specify an argument, which one will be called ? I don't know either.
valerie99 wrote:
got some assertion failed,
You should know more than that - you should go into debug mode from here to see where it happened, and find out what it was.
valerie99 wrote:
Warning: skipping non-radio button in group.
This means you have a dialog box where the radio buttons were not all put on at once, but it's still trying to group them together. No big deal.
valerie99 wrote:
could anyone tell me is it because of the warning C4520 or the assertion failed causing memory leak?
Neither, probably. The memory leak means you leaked memory, probably strings ? Do you use char * in your code ( you shouldn't, but still.... ). You should chase down the assertion, it's there to help you, and it can't if you don't pursue it. It may have something to do with your memory leak, but there's no more than a 50/50 chance of that.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi all,
Just a quick one. How do I grey out toolBarButtons? When I use the Enabled property my button completely disappears. I've read somewhere that this is a bug in .net - can't remember where or even if this event ever actually occurred . Does anyone have a work around for this or could you at least point me in the right direction.
Thanks
Rich
|
|
|
|
|
I previously had a single funcion which did some operation in a sequential manner. Since the code became very huge, I decided to split the function into smaller pieces, say around totally 5 functions. Something like this,
OLD CODE
void a()
{
1000 odd lines
}
NEW CODE
void a()
{
b();
c();
}
void b()
{
d(); //called multiple times
}
void d()
{
e(); //called multiple times
}
e() is a normal function.
Is there any way by which I can calculate the delta in performance theoretically?.
kramkrish
|
|
|
|
|
I doubt it. The only way to know is to actually test it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What is linkage and what is use of internal linkage and external linkage?
rajesh
|
|
|
|
|
The notion of linkage is kind of complicated because the word describes code properties that can be understood within several different contexts.
The most obvious is referring to the compiling process when the LINKER is invoked to supply code linking the object files in your project to another existing external binary Library (typically a DLL) of funtions and resources.
Another distinct context for the term 'linkage' involves the using terms like 'extern' preceeding function prototypes being imported via P/Invoke, or Interop, (unmanaged code being inserted into a managed environment). This merely prevents the Visual Studio compiler from managling the name of the function. This is referred to as 'specifying linkage'.
I frankly hate the language that Microsoft engineers use to describe their technologies. It can be, and often is, confusing as hell.
I suggest you be more specific about the context in which the term is being used. In this case, I have described only two of possibly a dozen or more conventional usages.
But, generally speaking, internal linkage is similar to execution scope, and external linkage refers to separate compiled binary entities and dependencies in other programming languages or compiled by other vendor compilers.
You might find this article helpful:
Mixed Language Programming and External Linkage[^]
|
|
|
|
|
hi,
Can I take or compute tahe address of register variable?
can I make register variable as global or static?
Please let me know reason.
rajesh
|
|
|
|
|
Do you mean a location in the registry ? No. If not, what do you mean ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
No, you can't take the address of a register variable - after all, what would its address be if it's in register?(!!) For the same reasons such vars cannot be static nor global.
|
|
|
|
|
Sorry, I should correct the last post, in ANSI C you can't take the address of an register var, in C++ you can. If you take the address of a register var, the compiler will place it in memory anyway.
Remember it's up to the compiler to decide which vars are placed in registers, so the register storage modifier is only a hint.
You cannot make such vars global or static.
|
|
|
|
|
I was wondering if somebody could tell me how self registering objects work when we use a anonymous namespace and static keywords. Is the registration done during compile time or run-time??
So, if i declare
//Create an Anonymous for the factory to self register frame classes, also such that the scope is limited to this file preventing the compiler from getting confused with methods of other frame types
namespace
{
Frame* createIFrame()
{
return new IFrame;
}
int FrameType = 1;
bool registered = FrameFactory::Instance()->registerFrameFn(1,createIFrame);
}
this code is inserted into the .cpp file of every class that is added new, how does the object registration occur without ever being called explicitly??
|
|
|
|
|
A method in an anonymous namespace is visible only to the cpp file in which it is written. It cannot be called from anywhere else.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The code sample is taken from Modern C++ Design by Andrei Alexandrescu. It works fine, registering the classes during compile time, why it works I do not understand. As you an anonymous namespace inside a cpp files that has the class definition,cannot be called externally.
But this method is called by ClassName::register and works fine.
|
|
|
|
|
I'm not sure I understand the scope of the code in question, but I suspect that Koenig lookup is the reason, if you're saying what I think you're saying.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think I did not phrase my question properly, let me try again:
factory.h
class Factory
{
.......
}
Rectangle.cpp //This implements the rectangle class, and will register itself with the factory
namespace
{
Shape *createRectangle()
{
return new Rectangle;
}
Factory::Instance()->registerShape(rect_id);
}
main.cpp
int main
{
Shape *s
s=Factory::Instance()->createShape(rect_id)
}
Factory is a singleton and Instance is the single point of entry. The part I do not understand is this, there is no explicit call to registerShape, it is inside the anonymous namespace. Every new shape will just include similar code to the one in the namespace, and by some compiler magic all these new shapes will get registered with the Factory with their id.
What exactly is the compiler magic, that register each new shape, does this happen dynamically or at compile time?
|
|
|
|
|
I think I did not phrase my question properly, let me try again:
factory.h
class Factory
{
.......
}
Rectangle.cpp //This implements the rectangle class, and will register itself with the factory
namespace
{
Shape *createRectangle()
{
return new Rectangle;
}
Factory::Instance()->registerShape(rect_id);
}
main.cpp
int main
{
Shape *s
s=Factory::Instance()->createShape(rect_id)
}
Factory is a singleton and Instance is the single point of entry. The part I do not understand is this, there is no explicit call to registerShape, it is inside the anonymous namespace. Every new shape will just include similar code to the one in the namespace, and by some compiler magic all these new shapes will get registered with the Factory with their id.
What exactly is the compiler magic, that register each new shape, does this happen dynamically or at compile time?
|
|
|
|
|
What do registerShape and createShape look like ? I can't see how this would work, either. There is no compiler magic to make methods call themselves.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hello can any body tell me whether there is ne library in c++ using which i can display a jpg image in c++ output window.or send me ne code for this program.
thanx
|
|
|
|
|
http://www.codeproject.com/bitmap/cximage.asp
|
|
|
|
|
Hi all,
I'm trying to show a form using show but I'm getting some odd behaviour. Here's the code,
<br />
SplashScreen* splash = new SplashScreen ();<br />
splash->Show ();<br />
<br />
if ( ! BCM->ValidateConfigurationFile () )<br />
{<br />
return 0;<br />
}<br />
else<br />
{<br />
if ( BCM->RunLoginScreen () )<br />
{<br />
Application::Run ( new NetworkView ( BCM->getAccessLevel () ) );<br />
}<br />
return 0;<br />
I want the splash form to stay open until it is closed in the RunLoginScreen () method. The form however doesn't open until the login method opens a login screen. Can anyone tell me why I'm getting this behaviour.
Thanks in advance guys.
|
|
|
|
|
Right, new probelm.
Apparently it wasn't a problem with the show method, it's a problem with the pictureBox. I can't seem to use a pictureBox whilst using the form->Show () method. If I use ShowDialog () then alls good but this isn't what I need to do.
Does anyone have any idea why I can't use, or more correctly, why my pictureBox images won't show when I use form->Show (); Or an alternative way to go.
|
|
|
|
|
Given the declaration. int *a; The statement. a = new int [50]; Dynamically allowcates an array of 50 components of the type?
int, int*, pointer, address?
|
|
|
|
|
You get a pointer to an array of 50 unique integers.
|
|
|
|
|
int* a; declares a as a pointer to an int .
a = new int[50] allocates an array of 50 int , and then returns the address of the array in memory into a.
then, you can code a[1] to access the 2nd cell on the array.
if you wanted an array of pointers to int, you should write this :
int* a;
a = new int*[50];
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|