c++

Multiply a constant to a complex & operator overloading problems

Complex operator*(double m, const Complex & c) { return c * m; } *On the code above, i'm trying to multiply a constant to a complex number. i receive some errors one of them is [ binary 'operator ' has too many parameters] ostream & operator<<(ostream & os, Complex & c) {os << c.real <<...

Setting up visual studio c++ 2008 with mysql c api

Hello, I'm wondering if anyone can help me on getting my visual studio c++ project setup correctly to work with MySql? I downloaded and installed MySql Server, and installed the developer content with the include files, but beyond that I'm a bit lost. I tried adding the 'include' directory in my MySql install path to my additional incl...

Template function with dependent type parameters within template class

Hi, I've been trying to do this simple stuff and Visual studio 2008 does not seems to like it. template <class CharType> class SomeClass { public: template <class T1, class T2> static bool SomeOperator(const typename T1::const_iterator& p_Begin1, const typename T1::const_iterator& p_End1, ...

Modifying binary files

Hi guys, I'm trying to write a small program which will search a binary file for a few bytes and replace these with another bunch of bytes. But everytime I try running this small app I got message about *istream_iterator is not dereferenceable*. Maybe someone have a suggestion how to do this in another way (iterators are a little bit a...

simulate C++ function template instantiation with implicit conversion

I already asked two questions related to what I'm trying to do (one resolved, one of which I will close soon). I know that C++ template instantiation does not allow any implicit conversions (see for example this comment), but I would like to simulate it. Suppose I have the following skeleton code: template <class T> struct Base_A{ ...

What is faster on division? doubles / floats / UInt32 / UInt64 ? in C++/C

Hi everyone, I did some speed testing to figure out what is the fastest, when doing multiplication or division on numbers. I had to really work hard to defeat the optimiser. I got nonsensical results such as a massive loop operating in 2 microseconds, or that multiplication was the same speed as division (if only that were true). After...

Visual Studio 2008 - Sharing Data in C++/C# Multi Project Solution

Hi, I have a solution with 2 projects: a c++ main project a c# project (display simulator) Today these 2 apps share data using a loopback TCP client/server connection, but that's not very optimal (timing issues..). I was wondering if there was a way to access the c# data from the c++ project directly and vice versa? (It seems to be...

Memory leak using multiple boost::connect on single slot_type

Hi, I'm using boost::signals and leaking memory when I try to connect multiple signals to a single slot_type. I've seen this same leak reported on various forums, but can't find any that mention the correct way to do this, or any workaround. What I am trying to do: I am trying to pass the result of boost::bind() into a function. In th...

How best to manage Linux's buffering behavior when writing a high-bandwidth data stream?

Hi all, My problem is this: I have a C/C++ app that runs under Linux, and this app receives a constant-rate high-bandwith (~27MB/sec) stream of data that it needs to stream to a file (or files). The computer it runs on is a quad-core 2GHz Xeon running Linux. The filesystem is ext4, and the disk is a solid state E-SATA drive which sh...

Define a struct in a midl generated header file

I am in the process of automating the build of a legacy product and have hit a wall... I have a .idl file that is compiled in VC++ 6.0 using midl to generate a .tlb, .h and .c file that has a manual build step to add: struct StructDef; Just ahead of an MIDL_INTERFACE in the generated .h file. The rest of the .h file uses the definit...

string program for ice cream shop (Edited again)

With the assistance of others, I have redone the code from scratch due to them pointing out numerous errors and things that wouldn't work. Thus I have changed the code massively. I have the program working other than two formatting settings that I can't figure out how to get to work. I need to only print "DAILY SCOOP REPORT" once at ...

how to turn off a unit test in CPPUnit

I (finally) have my app being unit tested with CPPUnit and I have CruiseControl.NET running the tests and displaying the test output. I have several tests that always fail, however, so CruiseControl always marks the build as failed. Is there any way I can "turn off" or "skip" or "ignore" these always-failing tests? I'd rather not just...

Is it possible to compile ImageMagick with custom libxml2 on the Mac

It always seems to pick up the version from /usr/lib and there doesn't seem to be a ./configure parameter to override it. ./configure --prefix=$PREFIX --with-quantum-depth=8 --disable-installed --without-x --without-perl --enable-static --disable-shared --with-jpeg --with-tiff CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" CFLAGS="$CFLAGS" --d...

Question about send / recv

New to socket programming. Got a couple questions: My program is really inconsistent with its output. Sometimes my client receives, sometimes it doesnt. I am also using the same input each time. Just need confirmation: Can the number of bytes received be less than the number of bytes sent from the server? How do I make it so that I st...

What is the most efficient implementation of a java like object monitor in C++?

In Java each object has a synchronisation monitor. So i guess the implementation is pretty condensed in term of memory usage and hopefully fast as well. When porting this to C++ what whould be the best implementation for it. I think that there must be something better then "pthread_mutex_init" or is the object overhead in java really so...

How does an insert sort for an array BST work?

I've tried to do it recursively..The parent integer varaible would is like i, conforming to the formula, 2*i +1 for leftChilds and 2*i +2 for the right. void BST::insert(const data &aData) { if ( items[Parent].empty ) { items[Parent].theData = aData; items[Parent].empty = false; } else if ( aData < items[Paren...

Sun Raster images: Why 1 byte row padding when width is odd?

This may be waaay to specific for SO, but there seems to be a dearth of info on the sun raster standard. (Even JWZ is frustrated by this!) Intro: The Sun raster standard says that rows of pixels have padding at the end such that the number of bits in a row is a factor of 16 (i.e. an even number of bytes). For example, if you had a 7-p...

How can I schedule some code to run after all '_atexit()' functions are completed

I'm writing a memory tracking system and the only problem I've actually run into is that when the application exits, any static/global classes that didn't allocate in their constructor, but are deallocating in their deconstructor are deallocating after my memory tracking stuff has reported the allocated data as a leak. As far as I can t...

C++ segmentation fault when trying to output object functions

I am attempting to output functions common to a set of objects that share a base class and I am having some difficulty. When the objects are instantiated they are stored in an array and then I am attempting with the following code to execute functionality common to all the objects in this loop: if ( truck <= v ) // all types of truck...

File I/O in C++

I have a data file where I need to read a datum from each line and store it. And then depending on the value of one of those datums store that data in an array so that I can then calculate the median value of all of these data. The line of data is demographic information and depending on the geographic location, address of a person. I n...