c++

Boost Libraries on Monodevelop

Hi, I am trying to link some Boost .hpp files with Monodevelop, but I don't know how to tell the IDE where Libraries are. If I want to include the array.hpp file, I write #include<directories/array.hpp>, but because this file makes calls to other files, and the directories to those files in the array.hpp file are only /boost/somefile,...

C++ array excercise-help needed

Hello, I'm C++ begginer. I did this excercise from Deitel's book: Use a one-dimensional array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, validate it and store it in the array only if it is not a duplicate of a number already read. After read...

Is Template Metaprogramming faster than the equivalent C code ?

Is Template Metaprogramming faster than the equivalent C code ? ( I'm talking about the runtime performance) :) ...

Sockets - send and receive

Hey, I'm currently writing a chat server in C++. When a user connects to it, I open a socket and I create two threads, one to receive and one to send data. Now my question: Do I have to check if the other thread is currently using the socket, or will the send/recv function just wait until the socket is ready? Regards, x3ro ...

Tracing memory corruption on a production linux server

Guys, could you please recommend a tool for spotting a memory corruption on a production multithreaded server built with c++ and working under linux x86_64? I'm currently facing the following problem : every several hours my server crashes with a segfault and the core dump shows that error happens in malloc/calloc which is definitely a s...

Filter C++ through a perl script?

I have a perl script I'd like to filter my cpp/h files through before gcc processes them normally -- basically as an extra preprocessing step. Is there an easy way to do this? I realize I can feed the cpp files to the script and have gcc read the output from stdin, but this doesn't help with the header files. ...

C++ Constructor call

I have written this small code snippet in C++, the output is also attached. I fail to understand why the constructor is being called only once, while i can see two calls being made for destructor. From what i understand, default constructor and overloaded assignment operator should be called at line 28. Can someone please throw some li...

How do Concepts differ from Interfaces?

How do Concepts (ie those recently dropped from the C++0x standard) differ from Interfaces in languages such as Java? ...

Problem in running boost eample blocking_udp_echo_client on MacOSX

I am trying to run blocking_udp_echo_client on MacOS X http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/example/echo/blocking_udp_echo_client.cpp I run it with argument 'localhost 9000' But the program crashes and this is the line in the source which crashes: `udp::socket s(io_service, udp::endpoint(udp::v4(), 0));' this is t...

MongoDB and visual C++ 2008 linker errors

i'm trying to get the c++ client for mongodb working in visual studio 2008. i can reference the includes, but whenever i tell the linker about the mongodb .lib file i get the following error: "fatal error LNK1257: code generation failed". if visual studio can't find the .lib, then i get a bunch of unresolved externals errors. i'm really ...

C++ templated container class: How to best support both ordered and un-ordered item types?

Hi all, I'm writing a templated C++ generic container class that can optionally maintain its contents in a well-defined order. Previously it used function pointers to order its contents in a sensible type-specific way, but I am attempting to change it to use templated functor arguments instead. Since it's often the case that the clas...

How to divide a string into parts - Roman numerals

I'm trying to divide a string into parts for reading Roman numerals. For example if the user enters "XI" I want the program to be able to understand that I is 1 and X is 10 in order for a data validation like this to work. if(string roman == "X") int roman += 10; etc. ...

Trying to make a void function edit a 2D array!

Okay, this is kind of a newbie question, and I understand that the function parameters I gave for the function in question are probably horribly off, but here's what I'm trying to do: I've got an 80x25 2D array of CHAR_INFO's (buffer) that will be printed to the console screen every iteration of the infinite loop. Because the buffer wi...

How to fix fringe cases in BST delete function?

Assume that my delete tries to rebalance the tree inorder (left to right). I'm writing a BinarySearchTree class currently, and my delete function currently works (I believe - I hope <3) in most cases. I have a few fringe cases to contend with: Deleting the root node won't work, because it has no parent. In the final case where next ha...

Multi-Resolution occupancy grid maps data structure

Where can i find an implementation of the Multi-Resolution occupancy grid map . its used in game engines and a lot in robotics and comes under spatial data structures? is there a c++ / java library ? ...

C++ derive from a native type

In some C++ code, I use integers to store lots of changing data. To analyze my program, I want to log certain changes to some of the variables, such as how often a certain value is assigned to, and how often that assignment is redundant (the new value is the same as the old value.) If the type were a class Foo, I'd just derive a new Log...

Accessing a bitmap resource fails with error code 0x716

So I don't know why I keep getting this error. Here's the relevant code: //////////////////////// In resource.h /////////////////////////// //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by Freestyle.rc // #define IDB_BITMAP1 101 // Next default values for new objects // #ifdef APSTUD...

How to send POST request to some website using winapi?

I'd like to send HTTP POST request to website and retrieve the resultant page using winapi. How can I do that? Thanks i advance. ...

What is the meaning of this C++ Error std::length_error

While running my program I get this Error: terminate called after throwing an instance of 'std::length_error' what(): basic_string::_S_create Abort trap I know that you can't do much without the code but I think that error is to deep in the code to copy all of it. Maybe I can figure it out if I understand what this error means. I...

Python Properties & Swig

I am attempting to create python bindings for some C++ code using swig. I seem have run into a problem trying to create python properties from some accessor functions I have for methods like the following: class Player { public: void entity(Entity* entity); Entity* entity() const; }; I tried creating a property using the python pr...