c++

C++ detecting end of file

I have a C++ program that is reading in info from a file, that stores info seperated by "$$$$". An example of how the file looks is: abc bcd $$$$ def $$$$ qwe gfh $$$$ How can I detect the file has ended, without using the eof() function? I have it set like this, getline(sin,temp) if (temp=="$$$$") { } After reading the last set o...

Good hash function for a 2d index

I have a struct called Point. Point is pretty simple: struct Point { Row row; Column column; // some other code for addition and subtraction of points is there too } Row and Column are basically glorified ints, but I got sick of accidentally transposing the input arguments to functions and gave them each a wrapper class. ...

Find number of differences in 2 strings

int n = string.numDifferences("noob", "newb"); // 2 ?? ...

finding "distance" between two pixel's colors.

Once more something relatively simple, but confused as to what they want. the method to find distance on cartesian coordinate system is distance=sqrt[(x2-x1)^2 + (y2-y1)^2] but how do i apply it here? //Requires: testColor to be a valid Color //Effects: returns the "distance" between the current Pixel's color and // ...

Can I use Visual Studio's testing facilities in native code?

Is it possible to use Visual Studio's testing system with native code? I have no objection to recompiling the code itself under C++/CLI if it's possible the code can be recompiled without changes -- but the production code shipped has to be native code. The Premium Edition comes with code coverage support which I might be able to get ch...

Is it possible to reinterpret pointer as dimensioned array reference?

hi. Suppose I have some pointer, which I want to reinterpret as static dimension array reference: double *p; double (&r)[4] = ?(p); // some construct? // clarify template< size_t N> void function(double (&a)[N]); ... double *p; function(p); // this will not work. // I would like to cast p as to make it appear as double[N] Is it p...

C++ meta Programming to create a new typelist with remove_const applied to each element

Hi Could anyone give me a sample program to "Create an ApplyRemoveConst template that constructs a new typelist with remove_const applied to each element" For example: typedef TYPELIST_3(A, const B, B) TL; typedef ApplyRemoveConst<TL>::Result TL2; // TL2 is the same as TYPELIST_3(A, B, B) //Typelist Definition: template<class T, cla...

activate RTTI in c++

Hi, Can anybody tell me how to activate RTTI in c++ when working on unix. I heard that it can be disabled and enabled. on my unix environment,how could i check whether RTTI is enabled or disabled? I am using the aCC compiler on HPUX. ...

fastest (low latency) method for Inter Process Communication between Java and C/C++

Hello, I have a Java app, connecting through TCP socket to a "server" developed in C/C++. both app & server are running on the same machine, a Solaris box (but we're considering migrating to Linux eventually). type of data exchanged is simple messages (login, login ACK, then client asks for something, server replies). each message is a...

When I run cxxtest I get this error that I dont underdstand?

./cxxtest/cxxtestgen.py -o tests.cpp --error-printer DrawTestSuite.h g++ -I./cxxtest/ -c tests.cpp g++ -o tests tests.o Color.o tests.o: In function `DrawTestSuite::testLinewidthOne()': tests.cpp:(.text._ZN13DrawTestSuite16t… undefined reference to `Linewidth::Linewidth(double)' tests.cpp:(.text._ZN13DrawTestSuite16t… undefined reference...

parse localtime in c++

Is there an easy "beginner" way to take the current time using to a Date object that has int month int day int year for it's member variables? Thanks. ...

How can I convert wav to wma programatically in C++?

How can I convert wav to wma programatically in C++? ...

How to include clean target in makefile

I have a makefile that looks like this CXX = g++ -O2 -Wall all: code1 code2 code1: code1.cc utilities.cc $(CXX) $^ -o $@ code2: code2.cc utilities.cc $(CXX) $^ -o $@ What I want to do next is to include 'clean target' so that every time I run 'make' it will automatically delete the existing binary files of code1 and code2 bef...

Error while Trying to Hook "TerminateProcess" Function. Target Process crashes. Can anyone help me ?

Debugging with visual studio 2005 The following Error Displayed :Unhandled exception at 0x00000000 in procexp.exe: 0xC0000005: Access violation reading location 0x00000000. And Thread Information: 2704 Win32 Thread 00000000 Normal 0 extern "C" VDLL2_API BOOL WINAPI MyTerminateProcess(HANDLE hProcess,UINT uExitCode)...

How are classes more secure than structures ?

Structure's member are public by default ans class's members are private by default. We can access private data members through a proper channel (using member function). If we have access to member functions we can read/write data in private data member, so how it is secure...we are accessing it and we are changing data too..... ...

Call a void* as a function without declaring a function pointer

I've searched but couldn't find any results (my terminology may be off) so forgive me if this has been asked before. I was wondering if there is an easy way to call a void* as a function in C without first declaring a function pointer and then assigning the function pointer the address; ie. assuming the function to be called is type vo...

log4j/log4cxx : exclusive 1 to 1 relation between logger and appender

Using the xml configuration of log4cxx (which is identical in configuration to log4j). I want to have a certain logger output exclusively to a specific appender (have it the only logger which outputs to that appender). I found that it's possible to bind a logger to a specific appender like this: <logger name="LoggerName"> <level va...

Size of abstract class

How can I find the size of an abstract class? class A { virtual void PureVirtualFunction() = 0; }; Since this is an abstract class, I can't create objects of this class. How will I be able to find the size of the abstract class A using the 'sizeof' operator? ...

Java vs c++ types

I've recently had a question about coledatetime java implementation, and Chris said, that the problem might lay in type conversions: cpp-float vs java-float (Or maybe cpp-date vs java-date. Not types, but..). Now I have several questions on this: Is there a table of comparison for java vs c++ types? If type conversions is the problem, ...

RAII tutorial for c++

Hi. I'd like to learn how to use RAII in c++. I think I know what it is, but have no idea how to implement it in my programs. A quick google search did not show any nice tutorials. Does any one have any nice links to teach me RAII? ...