c++

static public member function ( C++ )

Hi, I need to count the times my public member function creates new data in a loop. Each time data is read it is saved into a private member varaible. Nothing is overwritten. // my classType.h const int ImpliedIndex = 1000; class classType { private: char privateMember[ImpliedIndex]; char privateMember2[ImpliedIndex]; public: st...

Why is the size of my vector full of structs so large when I load it's serialization in from a file?

As most of you may be following my line of questions already know, i'm trying to create a program that can serialize multiple structs to a .dat file, read them back in via loading it's serialization, edit the contents, and then re-write them to the file and so on. It's a inventory program I am trying to do and I can't get it to work for ...

C++ std::transform side effect

I've implementation of UnaryOperation like this struct Converter { Converter( std::size_t value ): value_( value ), i_( 0 ) {} std::string operator() ( const std::string& word ) { return ( value_ & ( 1 << i_++ ) ) ? word: std::string( word.size(), ' ' ); } std::size_t value...

GCC/Make Build Time Optimizations

We have project which uses gcc and make files. Project also contains of one big subproject (SDK) and a lot of relatively small subprojects which use that SDK and some shared framework. We use precompiled headers, but that helps only for re-compilation to be faster. Is there any known techniques and tools to help with build-time optim...

C++ runtime required?

Why do some C++ projects require a runtime package to be installed, while others do not? EDIT:How to make a project to work without the runtime? ...

When will STL iterator be equal to zero?

I have a program which is like this list<int>:: iterator n = alist.begin(); while(n!= (list<int>::iterator)0) { printf("Element is %d\n",*n); n = alist.erase(n); } So here i am comparing iterator with zero. but after deleting the last element the compiler is showing this error. *** glibc detected *** ./new: free(): invalid p...

readv(), writev(), WSARecv(), WSASend()

Hi everyone, I hope you can help me out. I'm trying to send packets of 1000 bits across a network via TCP/IP and I was hoping to be able to use the Overlapped I/O technique in both Cygwin and Windows as well. In Cygwin, I am trying to use the "readv() and writev()" function calls to send 1000 bits across while in Windows, I am tryin...

C++: Inline functions and link time code generation

Up till a while a ago my code base was very close to #include hell. Every time I changed an even mildly important .h file practically all the files got recompiled. The main reason for such high header dependency was that I have many small functions that need to be inline and I was under the impression that for inline to work they need to...

Register Variables

I am having a C++ code which have lot of recursion involved . I am thinking of using register class for my variables . Do you think by doing so I will be saving stack memory and will improve the performance Thanks Sameer ...

ACE (C++): Not calling cancel_timer == MLK?

If a one-shot timer was scheduled via schedule_timer(timer,0,ACE_Time_Value(delay),ACE_Time_Value::zero) is cancel_timer required in order to avoid a memory leak? ...

How do I clear the std::queue efficiently?

I am using std::queue for implementing JobQueue class. ( Basically this class process each job in FIFO manner). In one scenario, I want to clear the queue in one shot( delete all jobs from the queue). I don't see any clear method available in std::queue class. How do I efficiently implement the clear method for JobQueue class ? I have ...

What am I doing wrong with my serializing a vector with structs in it to a .dat file?

If I type in Description: Apple Quantity: 10 Wholesale Cost: 30 Retail Cost: 20 Date Added: December These are the contents in my .dat file: 1Apple103020December But when I load my program, it doesn't load the struct back in correctly resulting in there being 0 items in my list. Is that what it is suppose to look like or am I do...

LoadLibrary fails when including a specific file during DLL build.

Hi I'm getting really strange behavior in one of the DLLs of my C++ app. It works and loads fine until I include a single file using #include in the main file of the DLL. I then get this error message: Loading components from D:/Targets/bin/MatrixWorkset.dll Could not load "D:/Targets/bin/MatrixWorkset.dll": Cannot load library Matrix...

How to respond with a custom error response in Apache 2.2 (c++)?

Hi, I am currently trying to have my Apache module repspond with custom error messages, so that a 400 for example contains additional information like "The coordinates are out of bounds". I found multiple sources on Google saying that it is possible, but none could tell me how. So is there some function that would allow me something lik...

Why won't my ofstream work when I put it outside my while statement?

Every time I do anything, and my while(1) gets called in my main function, my file gets cleared. It's driving me crazy. I've tried EVERYTHING. I try to put my ofstream out("data.dat"); outside the while(1) statement so it isn't called everytime but then nothing is written to the file like the ofstream isn't even working! I've tried to m...

How can I know the address of owner object in C++?

Hi, I would like to create in C++ a Notifier class that I will use in other objects to notify various holders when the object gets destroyed. template <class Owner> class Notifier<Owner> { public: Notifier(Owner* owner); ~Notifier(); // Notifies the owner that an object is destroyed }; class Owner; class Owned { public: Owned(...

debug stack overflow in windows?

So I'm trying to debug this strange problem where a process ends without calling some destructors... In the VS (2005) debugger, I hit 'Break all' and look around in the call stacks of the threads of the misteriously disappearing process, when I see this: This definitely looks like a SO in the making, which would explain why the proce...

Windows: Overwrite File In Use

I am trying to write a utility that will allow moving files in Windows, and when it finds a file in use, will set that file to be moved on reboot. It seems that MoveFileEx (http://msdn.microsoft.com/en-us/library/aa365240(VS.85).aspx) is the right call for this, however I cannot figure out what error code I'm looking for from GetLastErr...

How to load all files from a directory?

Like the title says; how do I load every file in a directory? I'm interested in both c++ and lua. Edit: For windows I'd be glad for some real working code and especially for lua. I can do with boost::filesystem for c++. ...

"No appropriate default constructor available" error in Visual C++

I don't get it. I've been staring at the code the code for three hours and I can't see the problem. The class I'm creating, called TwoDayPackage is derived from a class called Package. This is how I defined the constructor: TwoDayPackage(string, string, string, string, int, string, string, string, string, int, float, float, float)...