c++

Finding arguments that go with methods in C++ dll's

Ok, so I can use dumpbin.exe /exports library.dll to find all methods in the dll. ...but how do I find out which arguments to pass into them? Without a header file of course. ...

function pointer

Possible Duplicate: What is the point of function pointers? How pointer function work, and where is the difference ( not abstract like encapsulatin ) from methods ...

SDL + SDL_ttf: Transparent blended text?

Hi, This is a many discussed topic. But after searching for hours, I still could find how to do it... So, what I want is to render an anti-alias string on an SDL_Surface with a given alpha channel. It is possible to render: an anti-alias string with the Blended variant of the string render method. But then I can't make it transparen...

Algorithm to cover maximal number of points with one circle of given radius

Let's imagine we have a plane with some points on it. We also have a circle of given radius. I need an algorithm that determines such position of the circle that it covers maximal possible amount of points. If there are many such positions, the algorithm should return one of them. Precision is not important and algorithm may do small mi...

С++ how to delete object created in another thread

There is a long-time request and is called from the "main" (UI) thread. It is planned to move it's call into a separate thread. The problem is that some objects are created in this thread on the heap (main thread will have to work with these pointers). Questions: Is it allowed to delete 'another-thread' objects in the main thread? Is ...

C++ inheritance/template question

I have two classes, point and pixel: class point { public: point(int x, int y) : x(x), y(y) { }; private: int x, y; } template <class T> class pixel : public point { public: pixel(int x, int y, T val) : point(x, y), val(val) { }; private: T val; } Now here's my problem. I want to make ...

What is the meaning of SO_REUSEADDR (setsockopt option) - Linux?

From Linux man page: SO_REUSEADDR Specifies that the rules used in validating addresses supplied to bind() should allow reuse of local addresses, if this is supported by the protocol. This option takes an int value. This is a Boolean option When should I use it? Why does "reuse of local addresses" give? Thanks, Ray ...

Static member initialization in a template class

I'd like to do this: template <typename T> struct S { ... static double something_relevant = 1.5; }; but I can't since something_relevant is not of integral type. It doesn't depend on T, but existing code depends on it being a static member of S. Since S is template, I cannot put the definition inside a compiled file. How do ...

Where does the word trait comes from ?

I understand that C++ Traits are compile time properties that can be used to take some compile time choices for templates, but where does they come from ? Can anyone point out some basic background material about the concepts behind traits ? Where does the word traits come from ? EDIT: I guess I should refine the question. I know of ...

c++ unused memory of objects containing only pointers , how to free?

I've just written some threaded code which handles huge objects. Even when I clean up everything from an object (without deleting it), it keep eating GBs of RAM. FYI, I reproduced the issue in a smaller environment. This code creates a structure and an object containing a vector of pointers to the structure. Then I fill the object with ...

Call C/C++ code from a Fortran 77 code

Hi! I'm trying to make a Fortran 77 wrapper for C++ code. I have not found information about it. The idea is to use from functions from a lib that is written in C++ in a Fortran 77 progran. Does anyone know how to do it? Thanks! ...

How to read a user's input from the console into a Unicode string?

A C++ beginner's question. Here is what I have currently: // From tchar.h #define _T(x) __T(x) ... // From tchar.h #define __T(x) L ## x ... // In MySampleCode.h #ifdef _UNICODE #define tcout wcout #else #define tcout cout #endif ... // In MySampleCode.cpp CAtlString strFileName; if (bIsInteractiveMode) { char* ...

Finding a Subset of Points by Relative Distances

I'm writing a game in which the player may manipulate a great many objects at one time. I would like the player to be able to select objects according to the distances between them. Given the locations of all objects, a starting object, and a distance threshold, what is the fastest way to find the subset containing the starting object f...

boost shared_ptr and 'this'

I have two classes with a parent-child relationship (customer&order directory&file etc) I have typedef boost::shared_ptr<Parent> ParentPtr and in parent class a method to make a child I need child instances to have pointers to their parent. class Child { .... ParentPtr m_parent; .... } I want it to be a shared_ptr so that...

C++: How to know if a pointer points to the heap or the stack?

The title says it all. Example: bool isHeapPtr(void* ptr) { //... } int iStack = 35; int *ptrStack = &iStack; bool isHeapPointer1 = isHeapPtr(ptrStack); // Should be false bool isHeapPointer2 = isHeapPtr(new int(5)); // Should be true /* I know... it is a memory leak */ Why, I want to know this: If I have in a class a member-p...

Friend function cannot access private function if class is under a namespace.

Hi, I have a class inside a namespace and that class contains a private function. And there is a global function. I want that global function to be the friend of my class which is inside the namespace. But when I make it as a friend, the compiler thinks that the function is not global and it is inside that namespace itself. So if I t...

Read Anonymous Pipes More than Once while Keeping Connection Open (WinAPI)

So I keep bouncing between named and anonymous pipes and here is my issue. I tried named pipes and they just didn't seem to work properly for what I wanted, so I'm back to anonymous pipes. However, the anonymous pipe needs to read input from a pipe (to a program that I did not create) and continuously read it as more information is avail...

C++ Primitive datatypes: how to read unsigned 30 bits

Hi all, I have an array of unsigned chars. Basically I have an array of bits. I know that the first 16 bits corresponds to an unsigned integer and I retrieve its value using (u16)(*(buffer+ 1) << 8 | *abcBuffer) Then comes a data type called u30 which is described as follows: u30 - variable length encoded 30-bit unsigned integer va...

Is this the correct syntax for passing a file pointer by reference?

Is this the correct syntax for passing a file pointer by reference? Function call: printNew(&fpt); printNew(FILE **fpt) { //change to fpt in here kept after function exits? } Thanks. ...

Alternative to GLUTesselator?

I was wondering if there was a library or another way to produce multi contour polygons in OpenGL. I did code profiling and the GLUTesselator is killing my loop. Thanks ...