|
Hi, I have some answers perhaps.
1. You would override the global new and delete operatos if yuo wanted to use your own heap memory manager rather than the one in the C Runtime for all memory management in your process. C# does this to implement 'managed memory' for you.
You would override the new and delete operators within a class if you wanted to implement some special allocation scheme for instances of that class or to selectively make it use your own memory manager.
2. Log every allocation with a unique number and every deallocation with a matching number. One cancels the other, anything left at the end is a leak. Sounds simple but not easy in practice.
3. MACROs dont declare variables they do the equivalent of #define wordy SomethingElse. Unless SomethingElse is also validly decalred you can't use wordy as a variable.
4. What C++ can do that C can't is 'data hiding'. Declaring private or protected members in a class anf=d then giving access to them only through, for example, Get and Set functions. This allows you to error check and trace all accesses and potentially to change the underlying name or even type of the member without breaking any other code as long as the accessors still work and have the same signatures everything is
5. Yes, just remember to use the matching version of free.
6. global variables are global, enough said. Class statics are global but their names are class specific, so CAButton::s_MyStaticMember is refered to as such and does not clash with CAScroller::s_MyStaticMember which is a compleely different variable. C++ initializes statics using some Compiler/Linker trickery and bits bootstrap code in the CRuntime which can be a bit messy.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
3. Is there any difference in #define MAX 30 & const int max=30;?
5. How to use free in that case?
|
|
|
|
|
Aniket Salunkhe wrote: 3. Is there any difference in #define MAX 30 & const int max=30;?
Yes. #define MAX 30 just replaces each occurance of MAX in the code with 30 before it's compiled, const int max=30; declares a variable which will exist at runtime. In the first case int* pInt = &MAX; would give a compiler error in the second int* pInt = &max would be fine.
Aniket Salunkhe wrote: 5. How to use free in that case?
I can't honestly remember, it's years since I used calloc in anger. You'll need to either look at the docs or in the MS C Runtime source which ships as an optional install component with Visual Studio. Every memory allocation function e.g. malloc, calloc, has a specific matching from of free and it's especially important to match them up in Debug builds where they get mapped to diagnostic versions of the functions otherwise you'll get spurious leak reports and heap damaged block reports from the allocation tracking that is added to the debug functions. The CRT memory functions are a tangled multilayer mess, especially in Debug builds and it's not easy to track down the causes of problems after they've occured.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thank You Very Much
|
|
|
|
|
dear all
after i followed the book what it explained us how to use set left and right, but however after i set it, still problem. anyone can tell me detail, thanks
#include <iomanip>
using std::left;
using std::right;
using std::cout;
using std::endl;
for example: cout <<left<<name<<endl;
Li Zhiyuan
|
|
|
|
|
What is your problem?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
after i set left,output value can't be lefted by one column
Li Zhiyuan
|
|
|
|
|
Not sure I've understood. Could you please post an example?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
for example:
cout << setw(3)<<kk<<left<<setprecision(2)<<name<<endl;
but the output is still as follows:
1 jok
2 nice
.
.
.
10 mike
actually here name mike has same line with nice, jok..but mike is further front...
another question is setw(3), also couldnot work properly..no space display
Li Zhiyuan
|
|
|
|
|
If I understand your requirements then you probably need:
cout << right << setw(3)<< kk << " " << left << name << endl;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
thanks, i did like this before, could you provide me with detail step by step, thanks a lot. in vc++ 2005 format.
Li Zhiyuan
|
|
|
|
|
I posted a line of code. What details and steps do you need about?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi..
Just wanted some info on ways to automate VC++ builds. I am using Visual Studio .NET 2003.
Maybe some command line switches of devenv.exe ?
Regards
Amit
|
|
|
|
|
|
Thanks a ton Haroon! I was able to do my job
|
|
|
|
|
cagespear wrote: Just wanted some info on ways to automate VC++ builds.
Maybe some command line switches of devenv.exe ?
Yes. Thats the easiest way to go.
Alternatively, you could use a totally different build system like Microsofts nmake, scons or jam.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
As you mentioned it, have you ever got Jam to work? I tried it for building the Boost library and couldn't get anywhere with it. Do you perhaps know of any good tutorials for it?
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Matthew Faithfull wrote: As you mentioned it, have you ever got Jam to work?
Actually, no.
But it pops up in every review on build systems.
We used SCONS, and it worked.
Now, we are more and more switching to .NET and NANT.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Thanks, I'll check out SCONS at some point.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
You know this review[^]?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Nice article, thanks. I guess I'm not the only one who's had trouble with Jam then. Unfortunately I hate and am hopeless with make as well which is really disabling me from doing proper cross platform development. I guess I'm going to have to spend some time with a hefty make tutorial and write my own front end...Hmm XML to make using a recursive decent parser ... Visual Studio solution to platform indpendent XML using XSLT ... Visual Studio AddIn to export ... GCC build for MinGW ... next time I've got a spare month
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Wow! You have given a lot of stuff to read/know about, thanks dude!
|
|
|
|
|
hi
i have a application when i click the close button(X) , it must goes to the tray but it should be running ...
(i did a project when i click minimize button(_) it goes to tray . it is perfectly working)
k.guru moorthy
|
|
|
|
|
Have you tried to handle the WM_CLOSE event and write your code to send your application to tray there?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi,
I have a modal dialog with two edit boxes, one of them read-only, and a button. I want to transfer the integer written into the first to the second when the button is pressed.
I have added variables(int iVar, iCalcValue) to the edit-boxes and an event handler to the button, but I don't know where and how to write the data update code so the value is shown on the screen.
Sorry for such a silly question, I'll get better after some time
Thanks
|
|
|
|