c++

Generic transparent Qt widget that can catch clicks?

I've figured out how to use QPainter to draw rectangles. Now I want to have a drawing area where if the user clicks, a 1x1 rectangle is drawn where the mouse pointer is. To accomplish this, I assume I need a transparent Qt widget that supports the clicked() signal. How do I make such a transparent widget? Or is there something else I ca...

How to use VC++ intrinsic functions w/o run-time library

I'm involved in one of those challenges where you try to produce the smallest possible binary, so I'm building my program without the C or C++ run-time libraries (RTL). I don't link to the DLL version or the static version. I don't even #include the header files. I have this working fine. Some RTL functions, like memset(), can be use...

Is there something like a Filestorage class to store files in?

Is there something like a class that might be used to store Files and directories in, just like the way Zip files might be used? Since I haven't found any "real" class to write Zip files (real class as in real class), It would be nice to be able to store Files and Directories in a container-like file. A perfect API would probably look ...

C++ get method - returning by value or by reference

Hello! I've go a very simple question, but unfortunately I can't figure the answer myself. Suppose I've got some data structure that holds settings and acts like a settings map. I have a GetValue(const std::string& name) method, that returns the corresponding value. Now I'm trying to figure out - what kind of return-value approach woul...

Udp server sending only 0 bytes of data

Hi all, This is a simple Udp server.I am trying to transmit data to some clients,but unfortunetly it is unable to transmit data.Though send is running quite successfully but it is returning with a return value meaning it has send nothing.On the client they are receiving but again obviously,zero bytes. void* UdpServerStreamToClients(v...

2D polygon triangulation

The code below is my attempt at triangulation. It outputs the wrong angles (it read a square's angles as 90, 90. 90, 176) and draws the wrong shapes. What am I doing wrong? //use earclipping to generate a list of triangles to draw std::vector<vec> calcTriDraw(std::vector<vec> poly) { std::vector<double> polyAngles; //get angles ...

error C2440: '=' : cannot convert from 'bool' to 'bool *'

I'm getting said error on this line "b = true". Now Why am I getting this error? Aren't I pointing to TurnMeOn and thus saying TurnMeOn = true? class B{ void turnOn(bool *b){b = true} }; int main(){ B *b = new B(); bool turnMeOn = false; b->turnOn(&turnMeOn); cout << "b = " << turnMeOn << endl; } ...

Static variables within functions in C++ - allocated even if function doesn't run?

I've been reading up on C++ on the Internet, and here's one thing that I haven't been quite able to find an answer to. I know that static variables used within functions are akin to globals, and that subsequent invocations of that function will have the static variable retain its value between calls. However, if the function is never c...

Does a static object within a function introduce a potential race condition?

I'm curious about the following code: class MyClass { public: MyClass() : _myArray(new int[1024]) {} ~MyClass() {delete [] _myArray;} private: int * _myArray; }; // This function may be called by different threads in an unsynchronized manner void MyFunction() { static const MyClass _myClassObject; [...] } Is there a p...

doxygen C++ inline template documentation

hello. Is there some way to document template parameters like this: template< int N, ///< description typename T ///< description > rather than listing each parameter with tparam? please note that function arguments can be documented like this in current doxygen: void function(int a /**< description */); if there is not o...

Calling functions from main() in c++

Hello. I came across a program with 10 header and 10 source files. I read in my text book that the functions are called from main. But how can I pass data to so many functions from main()? ...

Write a serverside c++/openGL App, that is accessible via JavaScript

Hi, I am currently having an idea where I want to save an image from a c++/openGL application on demand from a browser. So basically I would like to run the application itself on the server and have a simple communication layer like this: JS -> tell application to do calculations (and maybe pass a string or some simple data) applicatio...

need a virtual template member workaround

Hello, I need to write a program implementing the visitor design pattern. The problem is that the base visitor class is a template class. This means that BaseVisited::accept() takes a template class as a parameter and since it uses 'this' and i need 'this' to point to the correct runtime instance of the object, it also needs to be virtu...

How to capture any key in X?

Hi, I am building an application for which I need to periodically get information about users keyboard. It is going to be user idle detection application. I have a fairly simple solution to periodically check if the mouse has been moved. But I can't figure any reasonable non root way to detect if the keyboard has been pressed. I was thi...

Simple Reliable UDP C++ Libraries

Hello, I am in need of a reliable UDP library. The one I wrote does not work too well and I would like to see what a 3rd party can do in the same circumstances. Enet will not work because of some "interesting" compile issues in xcode (I have another question on stack overflow about that). Any suggestions for a portable, reliable UDP l...

playing incoming video stream

Hi! all, I am writing an application which is a kinda video streamer.The client is receiving a video stream using udp socket.Now as I am receiving the stream I want to play it simultaneous.It is different from playing local video file lying in your hard disk in which case it can be as simple as running the file using system("vlc filename...

std::map insert segmentation fault

Why does this code stop with segmentation fault : class MapFile { public: /* ... */ std::map <unsigned int, unsigned int> inToOut; }; bool MapFile::LoadMapFile( const wxString& fileName ) { /* ... */ inToOut.insert( std::make_pair(input,output) ); } but when I put the "std::map inToOut;" just before "inToOut.insert" it...

C++ Design Question on template types

I have a templated class template <typename T> class MyContainerClass For types to be substituted for T, it has to satisfy many requirements: for example, get_id(), int data(), etc. Obviously none of the fundamental types (PODs) are substitutable. One way I can provide this is via wrappers for the PODs that provide these func...

What is more efficient? Using pow to square or just multiply it with itself?

What of these two methods is in C more efficient? And how about: pow(x,3) vs. x*x*x etc? ...

Parallel port with C#

Hello, I am trying to send data to LPT1 port with a C# program, unfortunately with no success.. I am using windows 7 x64. I tried both x86 and x64 (inpoutx64.dll) dll's.. With the x64 dll when I send: Output(888, 255); It just continues the program as everything went ok, but i can't see anything on my multimeter (only the static 0.02...