Members that were initialized have their destructors called automatically. So you use three resources (ok) and those classes manage a single resource each (also ok).
What you have is indeed bad: managing multiple resources.
@Tomaka17: the Initialize and Finizalize are static functions and allocate a static resource to be used by all instances.
So I need to call them once at startup and shutdown. By the way that's legacy code I'm working with and I don't have the freedom/time to redesign it all :$
It's okay. Like James said, "See; I don't like this chat already. If you had asked that on Stack Overflow, I'd have gotten at least ten rep per letter of that first answer ;-)"
It's easy to forget, though, so I copy-paste anyway. Also, the shortcut to fixed-font is indentation by four spaces. But like I said, it seems to be all or nothing. So you can't say "Here's my code:" and within the same message get fixed-formatting, unless the whole thing is. Hope that changes.
Hi Guys...I am facing one scenario which is leading to error .Scenario is My Process A ...binds a library L which has a static variable S..Now after some time Process A loads a DLL D, which also used same Static Library L.
@sat IIRC, all major Os's reference count shared libraries. So your process will have only one copy of L loaded, so the state of S should be what is what prior to loading.
But it sounds like you have motivation for asking, so instead of asking theoretical questions, why don't you just ask about your real problem? On SO, preferably.
@ GMan thanks ..My problem is that when DLL try to access Static variable it do not get the same which my Process A is having...i.e. state is different
It's totally outside of C++ to try and care how much memory you can address, and only has rudimentary means of finding out the potential range via the size. That kind of stuff is dependent on the implementation, not C++.
even heap manager doesn't know size of allocated memory, it only knows how much memory to free on free() call so you can't get allocated memory size by it's pointer
Provide QUALITY books and an approximate skill level. Add a short blurb/description about each book that you have personally read/benefited from. Feel free to debate quality, headings, etc. Books that meet the criteria will be added to the list.
Note: FAQs and other resources can be found in the...
If you write x = new char[3], heap manager will allocate 16 bytes (or 8, or 4) and will remember that it allocated 16 bytes, so on delete x it will free 16 bytes. And nowhere will be information that actual size of *x is 3.
More precisely, if the last modification time of a source file was after the last modification time of the compiled file (the .o) then it is recompiled, otherwise it isn't
hello guys, does anyone know a decision tree implementation(with continuous attributes) for c++, easy to install with such feature as saving its structure to file and loading from file?
fortunately mine one applies to both unix and windows. found one good lib, but its install guide is like "cd...make...make install", nothing about the existence of windows programmers lol
Is there a good way to isolate memory leaks? i have a problem described here: stackoverflow.com/questions/4013045/… and cant determine what exact line overwrites memory or what the hell happens in there.
@spoulson: Can you bit give hint for what kind of jobs and tasks are performed inn WTL..? I mean what kind of problems addressed and mapped in WTL as told by nXqd that google use WTL there....?
yup my self confused about the usage of WTL...? as nXqd addressed that google use it.. so I got excited to learn and use it myself. As before I was understanding that these are old folks and now MS introduce hell alot new technologies to use and work with. So wana learn and need to dig into.
@Anton but the order is the same, i'm just wanting to skip over a middle argument, its of a differing type though, can I still not do this? would function overloading be the way to go for this then?
@spoulson that was purely an example to ask my question, whilst I am sure one day I will need to know the single quotes should be used char, my question could have been asked with any type
@spoulson: Can you bit give hint for what kind of jobs and tasks are performed inn WTL..? I mean what kind of problems addressed and mapped in WTL as told by nXqd that google use WTL there....?
@thecoshman long is not a long float. is a type modifier that means integer type by default. there is no such thing as unsigned long with floating point. only 3 types have floating points: float, double, long double. nothing else.
If a game monster class has a function take damage, by having it take an unsigned float, I can take decimal damage, and not have to check if it is negative, so that the code is actually increasing the monsters health when it is dealing damage
@thecoshman i think it may be useful, but sad thing is, current machine commands dont support floating points operations with unsigned value. may be because of its representation in the memory. for years of computer science evolution unsigned floats havent born, there must be a reason for it, in my opinion.
@RogerPate "are you thinking of long doubles?" lol sounds weird :D
@thecoshman you can use abs(), if you're that paranoic :D you program must work with right values, not allowing to pass negative floats to damage function. So your example is not that good.
@Anton yes I know that I could use abs in the function to check the value is non negative, but If I could use a non negative type, my class will not have to worry about this
but that is just transferring the problem to some where else
Guys, need ur help. I have two files - Image.h and Image.cpp. when i include Image.h in my main.cpp, everything links right. When i add Image.cpp(which includes Image.h and several windows header files), linker fails with such message: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmtd.lib(newaop.obj)
yesh. yes i meant. what do i have to do if i have two projects in one solution, one of them is a static library which doesnt need mfc, and the second one uses mfc. What the heck do i have to write in all these millions of parameters for linker?
@thecoshman A .h file should include all the headers it needs to include. A .cpp file should include all the headers it needs to include. Those two sets of headers may (and probably will) be different.
@thecoshman image is not a reserved word and Visual C++ has no problem compiling a class named image.
@thecoshman Yes, but the .h file should not include anything it doesn't need. It is likely that the implementations of your classes (in the .cpp file) has more dependencies than the declarations of your classes (in the .h file)
@JamesMcNellis In VS2010, if i try to use the project > add lass and call my C++ class Image I get a warning saying that Image is reserved and can't be used
guys, why can this message appear when debugging in VS2008:"Unhandled exception at 0x00000000 in app.exe: 0xC0000005: Access violation reading location 0x00000000." i cant even determine(stack frame is filled with values like 0000000000) on what exact line program tries to read from 0 memory location, and how the hell its even possible?
@Tomaka17 vs usually tells me about out of range indices. i must have mentioned that this happens on some iteration, 144th or so, and iteration is always the same.
@spoulson bjarne's 0x faq page gives rationale for keeping the name, which is just a "project codename" anyway
also: "It's been called C++0x for a long time, and I don't see a reason to change that until we have an actual number, like C++11 or C++12. C++1x should be reserved for the immediately following version, which (IIRC) some people hope to have out around 2018 or so." – David Thornley
It's entirely too early for speculation on what C++ will be like after C++0x, but idle hands make for wild predictions.
What features would you find useful and why? Is there anything in another language that would fit nicely into the state of C++ after 0x? What should be considered for the nex...
Upfront: I know this is off-topic here, belongs to meta, and should be closed and moved to meta. I post it here nevertheless, so it will get seen by more people who watch the C++ tag. Feel free to move this to meta (I've even tried to already add the discussion tag, although I'm not sure it will ...
@GMan: for sorted vector vs. map it's not so much a matter of "insert frequently" as it is whether you have a mixture of inserting/search, or mostly insert all your data, then do searching. If it's a mix, map will usually win. If it's in phases: 1: insert, 2: sort, 3: search, then a sorted vector will usually win.
I don't think im going to be doing anything of that sort, just trying to read variables from a file and use them where appropriate. Probably will only be used once at initial execution.
Upfront: I know this is off-topic here, belongs to meta, and should be closed and moved to meta. I post it here nevertheless, so it will get seen by more people who watch the C++ tag. Feel free to move this to meta (I've even tried to already add the discussion tag, although I'm not sure it will ...
@GMan: Good idea, but I think this is a fault with StackOverflow in general, for all tags. Not just the C++ tag. Moderation in terms of closing stuff as duplicates should have required less points, so such questions could be closed faster.