c++

Ruby, C++, Swig some classes not being exported

I've been working on getting my library c++ Lavish working with ruby using swig. The issue is that only some of the classes I've included in the interface file can be used and I get no errors during compilation of the bundle or loading in ruby. My swig interface file can be viewed here. An example of what works and what doesn't. sean$ ...

Elementary C++ Type Confusion

I was reading the following text from Stanford's Programming Paradigms class, and I noticed that when the author uses the string class, the constructor does a function call that looks like this: string::string(const char* str) { initializeFrom(str, str + strlen(str)); } If the initializeFrom function takes two char* arguments, how...

Combining equal_range with bind2nd and binary_function

I have a sorted collection of class Thing { public: item a; item b; other data; }; vector<Thing> Things; using class MultiValuedComparator { public: item a; item b; MultiValuedComparator(item c, item d) { a = c; b = d; } }; Since I have duplicates of item a, and item b (but not other data), I...

Get FILE* from fstream

Possible Duplicate: Getting a FILE* from a std::fstream Is there a way to obtain a FILE* from an a iostream derived class? Particularly from an fstream? ...

wrote a SDL game using C++ and i want to deploy it.

I wrote this really simple game in SDL using C++ and now i want to show some of my friends who are on windows. I wrote my program in ubuntu 9.10 using code blocks. I want to take my source code and make a windows installer so they can install it and play. How can i go about doing this? ...

Reusing Memory in C++

Just wondering is this kind of code recommended to increase performance? void functionCalledLotsofTimes() { static int *localarray = NULL; //size is a large constant > 10 000 if (localarray == NULL) localarray = new int[size]; //Algorithm goes here } I'm also curious how static variables are implemented by modern c++ c...

What is stack unwinding?

What is stack unwinding? Searched through but couldn't find enlightening answer! Thanks in advance. ...

What is the meaning of a function parameter of type *& in C++ ?

After reading a description about swapping pointer addresses on Stackoverflow, I have a question about C++ syntax for references. If you have a function with the following signature: void swap(int*& a, int*& b) What is the meaning of int*& ? Is that the address of a pointer to an integer? And furthermore being that it is a pointer re...

Declaring namespace as macro - C++

In standard library, I found that namespace std is declared as a macro. #define _STD_BEGIN namespace std { #define _STD_END } Is this a best practice when using namespaces? The macro is declared in Microsoft Visual Studio 9.0\VC\include\yvals.h. But I couldn't find the STL files including this. If it is not included, how it c...

Problem creating a circular buffer in shared memory using Boost

Hi, I am trying to create a circular buffer in shared memory using Boost circular_buffer and Interprocess libraries. I compiled and ran the the example given in the Interprocess documentation for creating a vector in shared memory with no problem. However, when I modify it to use the Boost circular_buffer as: int main(int argc, char *...

How to parametrize on iterator direction?

Basically I'm doing the following: std::set<int> indices; // ..fill indices if (flag) { // we need to process in ascending order BOOST_FOREACH (int i, indices) { process(i); } } else { // we need to process in descending order BOOST_REVERSE_FOREACH (int i, indices) { process(i); } } I wonder if ...

"Top-down discussion of design"

I need to write a lab report for a program I made. I need to provide a "top-down discussion of design." What does that mean? ...

Does the size of an int depend on the compiler and/or processor?

Hi, this was an interview question! would the size of an integer depend upon the compiler or processor? ...

How do I color / texture a 3d object dynamically ?

I have a 3D model, composed of triangles. What I want to do is, given a point near to the model, I would like to color the model (triangles) to another color, say blue. Right now, I have a bounding sphere about the model, and when the collision occurs, I just want to approximately color the portions of model from where the collision occ...

Why can't i set a member variable of an interface class as follows.

So i have a interface class class interfaceClass { public: virtual void func1( void ) = 0; virtual void func2( void ) = 0; protected: int m_interfaceVar; } and a class that inherits from it. Why can't i set the member variable of the interface class as follows. class inhertitedClass : public interfaceClass { inher...

C++ crash dump, stack unwinding on Win32 exceptions (when catch(...) used) - VS 2003

Like in Just In Time debugging, does VS 2003 compiled apps catch Win32 (or asynchronous) exceptions in a catch (...) and unwind the stack? before the dump file is written... ...

How to access a RGB image data

I want the data at pixel to be compared with the colour and then i want to find contour then take centroid points of the contour ,so i am using like this to find countourdata am i wrong at this statement int pos = i * w * Channels + j; //channels is 3 as rgb // if any data exists if (data->imageData[pos]>0) Code i...

Dom Vs Sax - creating Xmls

Hey, I know the difference between Sax and Dom is pretty substantial regarding parsing Xml, but what about creating ones ? is there even a way to create new Xml using Sax or that if i want to create new Xml file based on my data in my program , i will have to use DOM ? Thanks ...

trying to copy data with memcpy, getting error "Access violation writing location"

I'm getting error on second memcpy memcpy(&check_user, &ZZZ, (int)&main - (int)&check_user); "Unhandled exception at 0x72cc1f57 (msvcr100.dll) in 11.exe: 0xC0000005: Access violation writing location 0x00f31000." What is wrong? #include <stdio.h> #include <tchar.h> #include <windows.h> #include <stdio.h> #include <iostream> #define P...

Fixed/variable length structure in c# and big endian conversion

Struct { byte F1[2] SHORT F2 byte F3[512] } BPD CBD { SHORT CLENGTH byte DATA[] } Above are 2 c++ structure. Here SHORT is of 2 byte signed. What would be the best way to convert it into C#? (Note that in 2nd struture length of DATA is uundefined.) I have seen following two links. http://stackoverflow.com/questions/415214/fix...