c++

linker error: undefined reference c++

I've tried looking at similar problems, but could not easily find one that helped my problem. I've created a project in C++ and am working on UNIX to compile, link, and run it. My specific problem is an undefined reference to a method I declare in a separate file. In the file SharedCache.cpp, I have the following method: int SharedCac...

Making a Point class in c++

Right now I am using std::pair to represent a 2d point in c++. However, I am getting annoyed with having to write typedef std::pair<double, double> Point; Point difference = Point(p2.first - p1.first, p2.second - p1.second); instead of being able to overload operator+ and operator-. So, my question is, to ma...

isAbstract template and visual studio

The following template will decide if T is abstract with g++. /** isAbstract<T>::result is 1 if T is abstract, 0 if otherwise. */ template<typename T> class isAbstract { class No { }; class Yes { No no[3]; }; template<class U> static No test( U (*)[1] ); // not defined template<class U> static Yes test( ... ); // not d...

How can I inhibit warning 4200 in Visual Studio 2005?

I can inhibit many warnings in Visual Studio 2005 SP1 in the C/C++ Advanced property page, which causes the IDE to use the /wd switch on the command line which invokes the compiler. However, when I try to inhibit warning 4200 (nonstandard extension used : zero-sized array in struct/union), it still appears when I compile. (Of course it's...

What is that - Programming technic? (Boost Library)

Hi, I'am trying to understand the example from program_options of the boost library (http://www.boost.org/doc/libs/1_38_0/doc/html/program_options/tutorial.html#id3761458) Especially this part: desc.add_options() ("help", "produce help message") ("compression", po::value<int>(), "set compression level") ; what exactly is he ...

64 bit ntohl() in C++ ?

The man pages for htonl() seem to suggest that you can only use it for up to 32 bit values. (In reality, ntohl() is defined for unsigned long, which on my platform is 32 bits. I suppose if the unsigned long were 8 bytes, it would work for 64 bit ints). My problem is that I need to convert 64 bit integers (in my case, this is an unsigned...

DLL References in Visual C++

I am a C# developer who has decided to pursue a C++ project. I have had C++ experience but not MSVC. What I am trying to do is incorporate a .dll from an open source project into my project. The code is available and I have built it. I have the .dll as well as the .lib which as I understand it is required for C++ projects. Now unfortun...

How does const after a function optimize the program?

I've seen some methods like this: void SomeClass::someMethod() const; What does this const declaration do, and how can it help optimize a program? Edit I see that the first part of this question has been asked before... BUT, it still doesn't answer the second part: how would this optimize the program? ...

What is the error in this code?

I have created a code in C++ that is supposed to display an O and an X, and you can move the O with w/a/s/d, and the X moves randomly. It compiles fine, but when I run it, there is an O, but no X. I put the source code here: #include <iostream> using namespace std; //program class: defines player, enemies and powerups #include<stdlib...

C++ - Passing Arrays To Methods

Hello, Here is a function similar to the one I've defined: void Function( BYTE *data ); What I would like to do is something like this: Function( new BYTE { 0x00, 0x00 } ); ...

Portable shared objects?

Is it possible to use shared object files in a portable way like DLLs in Windows?? I'm wondering if there is a way I could provide a compiled library, ready to use, for Linux. As the same way you can compile a DLL in Windows and it can be used on any other Windows (ok, not ANY other, but on most of them it can). Is that possible in Lin...

Help installing C++ for Netbeans

Hello, I am trying to install c++ for netbeans.. I tried installing the cygwin and mingw but i can't compile because the make file that comes with Mingw is incompatible .. ...

Fastest code C/C++ to select the median in a set of 27 floating point values

This is the well know select algorithm. see http://en.wikipedia.org/wiki/Selection_algorithm. I need it to find the median value of a set of 3x3x3 voxel values. Since the volume is made of a billion voxels and the algorithm is recursive, it better be a little bit fast. In general it can be expected that values are relatively close. Th...

What utf format should boost wdirectory_iterator return?

If a file contains a £ (pound) sign then directory_iterator correctly returns the utf8 character sequence \xC2\xA3 wdirectory_iterator uses wide chars, but still returns the utf8 sequence. Is this the correct behaviour for wdirectory_iterator, or am I using it incorrectly? AddFile(testpath, "pound£sign"); wdirectory_iterator iter(test...

Driver for Broadcom ADSL modem

I am interested in writing a driver for my Broadcom NDIS ADSL modem. Given that I have knowledge in C and C++, what tool are needed for this job? ...

Throwing exceptions from constructors

Im having a debate with a co-worker about throwing exceptions from constructors, and thought I would like some feedback. Is it ok to throw exceptions from constructors, form a design point of view? Lets say I'm wrapping a posix mutex in a class, it would look something like this. class Mutex { public: Mutex() { if(pthread_mutex_...

Best library for audio file meta data?

I am looking for a library to read meta data from compressed and uncompressed audio files (i.e. mp3, ogg, etc.). In the past I have used libvorbis and id3lib, but I'm wondering if there are better libraries around? Ideally I would like a library that provides a common API to reading meta data from all the various formats. I realize more ...

Reading cookies from default browser in C++

Hello, I want to create a c++ application that works together with a website. In order to keep the application synchronized with the website I want to be able to read some cookies from the user's default browser. Is there any way to do this? ...

How big is the performance gap between std::sort and std::stable_sort in practice?

Both should run in O(n log n), but in general sort is faster than stable_sort. How big is the performance gap in practice? Do you have some experience about that? I want to sort a very large number of structs that have a size of about 20 bytes. The stability of the result would be nice in my case, but it is not a must. At the moment the...

Save memory when storing duplicate strings in a vector?

I'm using C++ and it's STL. I have a large (100MB+) text file. This file just has a lot of "words" (strings separated by whitespace) like: sdfi sidf ifids sidf assd fdfd fdfd ddd ddd I need to put each of these "words" in a vector: vector<string> allWordsInFile; So for each word that I read from the file, i do: allWordsInFile.pu...