c++

Unseen C++ syntax

A friend sent me this and I really don't know what it is, inside the loop. Whatever it be it calls the std::set constructor half million times.... any help appreciated. I would expect a compiler error, but it actually compiles in g++ 4.4 and 4.5 and the behavior is different to copy construction... #include <stdio.h> #include <stdlib.h>...

Is const_cast acceptable when defining an array?

I have a static const array class member (const pointers to SDL_Surfaces, but that's irrelevant), and have to loop through it in order to populate it. Aside from a const_cast when I'm done looping, which I hear is bad practice, how would I go about doing this? EDIT: The reason I don't just do... static SDL_Surface *const myArray[3]; ....

Declaring a pointer to multidimensional array: C++

I've tried looking but I haven't found anything with a definitive answer. I know my problem can't be that hard. Maybe it's just that I'm tired.. Basically, I want to declare a pointer to a 2 dimensional array. I want to do it this way because eventually I will have to resize the array. I have done the following successfully with a 1D ar...

Needed C++ HTML parser + regular expression support

I'm working on a C++ project and I need to find an external library which provides HTML parser and regular expression support. The project is under 2 OS - iOS & Android. I was thinking using libxml2 which has a HTML parser module and xml regular expression. Can I use the xml regular expression module on HTML page? In addition, I need...

3D array C++ using int [] operator

hi, I'm new to C/C++ and I've been cracking my head but still got no idea how to make an "structure" like this It's supposed to be a 3D dynamic array using pointers. I started like this, but got stuck there int x=5,y=4,z=3; int ***sec=new int **[x]; It would be enough to know how to make it for a static size of y and z; Plea...

how to traverse a grid of numbers using AB-pruning in C++?

Firstly I would like to accept that it is a homework question , but then I know how to code AB-pruning from the algorithm of it . The problem is how to apply it on a grid of numbers where the game can go on in any direction (right , left , up and down ) , thus how will be the tree formed . Sorry for being a bit vague here , if more inf...

What does this function definition mean?

This function definition is found here. : static void (*resolve_memcpy (void)) (void) { return my_memcpy; // we'll just always select this routine } I don't understand what it means. help? :D ...

Is there a chatbot framework available?

I am trying to create an program similar to ELIZA. My preference is to implement this project in a general language such as ruby, java, C++. is there some framework (open source would be great) available for any of these languages ? ...

How to parse a double formatted according to a locale settings in C++

I've found a problem with the strtod method which I've used all this time. First of all it doesn't understand non-point decimal separator, so I've forced to use this: std::replace(sSource.begin(), sSource.end(), getDecimalSeparator(), '.'); But no I've found another problem and didn't found how to resolve it yet. If the value is negat...

Update binary file information

Hi all We have some binary files on windows platform.(dll,exe and arx) But the file version information is wrong.(Right click->Properties->Details. The File version or project version are not correct.) Some of them are written by C#,some are C++. Because we don't have the source code for some of them. Is there any way to change the info...

How can I initialize a const variable of a base class in a derived class' constructor in C++?

I have an abstract C++ class with no constructor. It's supposed to be a base class so other classes can inherit from it. What I am trying to do is to declare a constant variable in the base class and initialize it in each derived class' constructor but nowhere else in each one of those classes. Is it legal in C++? If so, how can I do tha...

OpenMP library specification

hello , i am new to open mp and i tried an sample program from the official site #include <omp.h> #include <stdio.h> int main() { #pragma omp parallel printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads()); } and i have set the library in the eclipse as libgomp in project Properties->GCC c++ linker-...

Posix thread communication Linux

I have a worker thread which is alive from the start of the programme and would consistently take an object from a queue to process. I am wondering what is the best way to block the thread? The object would be pushed into the queue at about magnitude of every tens of microseconds( between 10 - 100 micro seconds). Should I set the thread ...

Can I write an Extension for External Harddisk

I want to secure my external hard disk by writing sort of ShellExtension. But Shell extension is Workstation Specific. Is there a way I can write an application that will show a authentication or an extension encrypt my drive data so user will get a failure message when double click on my drive. ...

Reference count when returning a shared_ptr

Does the following code mean that when this function returns, the request object inside this class still holds a reference to this object? boost::shared_ptr<Request> RequestList::GetRequest() { boost::mutex::scoped_lock(listmtx); request = boost::shared_ptr<Request>(new Request()); return request; } used: request = reques...

How to fix indentation in C, C++ and Fortran ?

Possible Duplicates: Code polisher / reformater for C, C++ or Fortran Best C++ Code Formatter/Beautifier I have code in C, C++ and Fortran (both f77 and f95) in a strong need for proper indentation (that is: they have none). I remember some tool to fix indentation, although I'm unable to find it, and as far as I recall, it j...

Unicode File Writing and Reading in C++?

Can anyone Provide a Simple Example to Read and Write in the Unicode File a Unicode Character ? ...

boost::filesystem::path and std::string

Hi, I have a String class which has a member std::string. One of the constructor is String (std::string s) { // member: std::string _mString; _mString = s; // error on path assignment } I now have functions that take String as parameter, e.g. Load(String path); but it turns out that boost::filesystem::path::string() is inc...

FIX communication model - messaging or socket

My situation is: A c++ program needs to talk with a Java program using FIX protocol. My solution: - Messaging: C++ program publishes a text in FIX format which Java progrma can consume and parse with quickfix/j. - Socket: Setup a FIX server in Java program, then C++ program as a client can connect to this socket and write byte stream...

Is there any perf hit using DLL functions?

As the title says, compared to a normal function, is there a perf hit in calling dll functions? The dll will be loaded by dlopen. EDIT: Ignore dlsym time because I only do it once per each function. ...