c++

How do I bounce a point off of a line?

I'm working on writing a Pong game for my graphics class final project (I choose to write this, I wasn't assigned Pong) and I've run across a problem that wasn't addressed in either the book or the class. I'm trying to figure out how to bounce a point off of a line. The best method I can figure out to do this with is Calculate the ...

building a web crawler

im currently developing a custom search engine with built-in web crawler. for some reason im not into multi-threading, thus so far my indexer was coded in single-threaded manner. Now i have a small dilema with crawler im building, can anybody suggest which is better, crawl 1 page then index it, or crawl 1000+ page and cache then index? ...

GetLastError() and calling unmanaged code in a static library from C++ .NET

I made a static library in Visual C++ 2008 Express Edition. It compiles to Win32 code in a file called static.lib. The functions in this library call SetLastError() to indicate errors or success. I have already succeeded in including this static.lib in a C++ Win32 DLL, and calling the DLL from C# using p/invoke and DllImport and SetLa...

Accessing a template base classes function pointer type

I have a class that I've been provided that I really don't want to change, but I do want to extend. I'm a pattern and template newbie experimenting with a Decorator pattern applied to a template class. Template class contains a pointer-to-member (if I understand the semantics correctly) in yet another class. The pointer-to-member is t...

Winsock error code 10014

string SendRequestToServer(std::string url) { struct sockaddr_in addr = { 0 }; struct hostent *host = NULL; // If the URL begins with http://, remove it. if(url.find("http://") == 0) url.erase(0, 7); // Get the host name. string hst = url.substr(0, url.find('/', 0)); url.erase(0, url.find("/", 0)); // Connect to the host. host = geth...

Can this be done without reading file twice? C++

Hi, What im doing here in main.cpp is reading a text file twice: once to remove the '\' from each path name, and again to supply the original name of the file to the SetPath() in my implementation File. // This a read file sub-routine called in the main function. // Its purpose was intentionally set out to read the file, and pass inform...

Lightweight OBJ mesh file loader for C/C++?

I'm looking for a simple lightweight Wavefront OBJ mesh file reader for C or C++. (ie. given a mesh in OBJ format, read it in from a file, and make it accessible, preferably as a list of vertices and triangles.) Recommendations? It doesn't need to support material properties or any other fancy data that might be present - just the geom...

What issues can I expect compiling C code with a C++ compiler?

If you take an existing C code base and compile it with a C++ compiler, what sort of issues can you expect to crop up? For example, I think that assigning an integer to an value with an enumerated type will fail in C++, whereas it's legal ( if a bit nasty ) in C. If I don't wrap all my C files in "extern C { ... }", am I going to get na...

Making all variables in a program modifiable at runtime by the programmer, smart idea?

I was thinking of doing this with C++, basically from an external editor or something the programmer can say: MyClass::dude = "hello" where 'dude' is a static integer in 'MyClass'. What the program does at runtime is it partitions the input to MyClass :: dude = "hello" and finds the class called 'MyClass' and assigns the dude variable i...

Do I need a job queue in my COM server?

I have a COM EXE out-of-proc server exposing an API from one of its interfaces. The functionality of this API is to post URLs. My client will be creating the instance of the COM server and calling this API with new URLs. Every time client needs to post a URL it will create an instance of this COM server. Do I need to implement a queue...

Is reducing number of cpp translation units a good idea?

I find that if there are a lot of classes the compilation time is dramatically increased when I use one *.h and one *.cpp file per class. I already use precompiled headers and incremental linking, but still the compile time is very long (yes I use boost ;) So I came up with the following trick: defined *.cpp files as non-compilable de...

How to Mix different compiler versions programs in visualstudio:?

HI our total project had Built on vs2003.earlier they have used SQLDMO in teheir project.Now we have palnned to use SQLSMO instead which must have .NETFRAMEWORK 2.0.But as of my knowledge vs2003 runs under .netframework1.1. Now my question is how to mix these two. my thinking is in my machine i have alresdy .NETFRAMEWORK 2.0 inst...

validating CEdit without subclassing

Is there any way to validate the contents of a CEdit box without subclassing? I want to check for invalid filename characters in a CEdit box and not allow the user to input it at all (keypress should not be recorded, if pasted in the box, the invalid characters should just not make it to the edit box).. Is there any easy way to do this...

How to compile using framework libraries?

I have wrriten a managed code for SMO application.How can i comiled it using .NETFRAMEWORK2.0. i dont wnat to use visulastudio due to certain limitataions. how can i do this. can nay body help me in this regard. msbuild.exe TestMsBuild.sln /:t Rebuild /:p configuration=release gives error as TestMsBuild.sln : Solution file error ...

How to place a .net UserControl on a c++ cdialog in visual studio 6

Hi My task is pretty simple create a .net usercontrol and use it in a old visual studio 6 proejct. I have createt the usercontrol (its just a user control with a label), I then followed this guide (http://support.microsoft.com/kb/828736) and it seems to work fine. But how can I display the usercontrol? Do I have to use CreateControl, a...

ImageMagick vs GraphicsMagick

Hello there, I've found myself evaluating both of these libs. Apart from what the GraphicsMagick comparison says, I see that ImageMagick still got updates and it seems that the two are almost identical. So, what should I use for standard image manipulation using C++? (i.e. image load, filters, display) Thank you! QbProg ...

How do I dynamically change the text of a CMFCRibbonLabel

My CMDIFrameWndEx derived main frame window uses a CMFCRibbonStatusBar to which I add a CMFCRibbonLabel. I'd like to change the text of this label at runtime: m_pLabel->SetText(description); m_pLabel->Redraw(); It only updates the text but not the rectangle in which to draw it. So if the original text was too short, the new string won...

Object delete itself from container

So I have a container(any kind, probably std::map or std::vector) which contains objects of a class with some network thing running in a thread that checks if it is still connected (the thread is defined inside that class and launches when constructed). Is there any way I can make the object delete itself from the container when its dis...

How can I end a Lua thread cleanly?

My situation is that I'm using the Lua (C) API to execute a script held in a string. I would like the user to be able to terminate the execution of the script (this is essential if the script contains an infinite loop), how can I do this? lua_State *Lua = lua_open(); char * code; // Initialisation code luaL_dostring(L, code); ...

How to Compile a c++ program using .NET Framework libraries

Hi i want comile a my c++ program using .NETFRAMEWORK libraries only at command prompt.how can i do this ?? Plz help mee.. ...