c++

Is there an automated way to merge C++ implementation(.cpp) and header (.h) files

Hi, I am trying to create a unit test framework using CPPUnit for a large code base. I need to be able to test individual modules, all of which are part of a module tree that begins with a specific root module. Due to a non-technical reason, I cannot touch the production file (my original approach involved adding an ifdef to the root m...

Easiest way for a simple 3d app.

A friend of mine asked for a simple program. Input: Coordinates of some points, spheres, planes etc. ( from an excel document (strictly) ) Output: A 3D view of the input which the user can move the camera. The questions is, how can I do that easiest way. I have experience in C++, C#, Flash (AS), Java ...

C++ Array and Vector are hold values or references ?

In C++ we have value type (int, long, float, ...) and reference type (class, struct, ...). For value type, Array and Vector hold the actual values; For reference type, Array and Vector only hold the references to these objects; So when we put reference type into Array and Vector, we need to make sure those objects will exist long enoug...

In C++ networking, using select do I first have to listen() and accept()?

I'm trying to allow multiple clients to connect to a host using select. Will I have to connect each one, tell them to move to a different port, and then reconnect on a new port? Or will select allow me to connect multiple clients to the same port? This is the client code: int rv; int sockfd, numbytes; if ((rv = getaddrinfo(hostN...

Redirecting stdout to a gtkmm TextView widget

Hi, I'm looking for a way to redirect stdout to a Gtk::TextView widget in gtkmm. Ideally, I want it to work both on Windows and UNIX-like OSes. So far, I've tried to redirect stdout to a file, then monitor changes to this file using Glib, like so (highly inspired from the gtkmm examples on gnome.org) : #include <stdio.h> #include <fcn...

What is __declspec and when do I need to use it?

I have seen instances of __declspec in the code that I am reading. What is it? And when would I need to use this construct? ...

DLL and fully-specialized template class

Hello, Environment: Visual Studio 9, C++ without managed extensions. I've got a third-party library which exports a fully-specialized template class MyClass<42> defined in MyClass.h. It gets compiled into a helper loader .lib and a .dll file. The .lib file contains compiled code for this specialization, and necessary symbols. The MyCla...

DAO large query lockup on Win7 multicore

I have a C++ app that uses a Jet database through DAO. Large queries work well up through Vista but lockup under Win7 on a multicore machine. I have tried both jet 3.5 and 4.0. Both fail. I have tried disabling threads in calling prog (my app) - still fails. ...

C++ can I reuse fstream to open and write multiple files?

I have 10 files need to be open for write in sequence. Can I have one fstream to do this? Do I need to do anything special (except flush()) in between each file or just call open(file1, fstream::out | std::ofstream::app) for a each file and close the stream at the end of all 10 files are written. ...

Parsing XML using libxml

Hello, I've got a small problem with parsing XML. I cannot get the name of a child node. Here's my XML code: <?xml version="1.1" encoding='UTF-8'?> <SceneObject> <ParticleSystem> </ParticleSystem> </SceneObject> Here's how I parse the XML file: SceneObject::SceneObject(const char *_loadFromXMLFile, const char *_childType) { xmlNod...

Restrict application to one instance per shell session on Windows

There are a lot of solutions for restricting an application from running twice. Searching by process name, using a named mutex etc. But I all of these methods don't work if I want to restrict my application to the shell session. A user may have more than login session and shell on windows (right?)? If this is true I want to be able to r...

Intel Thread Building Blocks Concurrent Queue: Using pop() over pop_if_present()

What is the difference in using the blocking call pop() as compared to, while(pop_if_present(...)) Which should be preferred over the other? And why? I am looking for a deeper understanding of the tradeoff between polling yourself as in the case of while(pop_if_present(...)) with respect to letting the system doing it for you. This...

Please Help to make asynchronous socket server and client working ( written in C)

Hi, Could some please help me with these codes? I am trying to make client and server to communicate asynchronously. I mean both client and server don't wait for each other (e.g. when a server or client reads from recvfrom() and data are not present, it takes the last received one (what I named is backup). Here are the codes: client ...

C++ urljoin equivalent

Python has a function urljoin that takes two URLs and concatenates them intelligently. Is there a library that provides a similar function in c++? urljoin documentation: http://docs.python.org/library/urlparse.html And python example: urljoin('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html') ==> 'http://www.cwi.nl/%7Eguido/FAQ.ht...

What is the point of having string resources in C++?

I've never used string resources before so I would like to ask, when should I use them and why are they beneficial when I can just define a string? ...

How do we typedef or redefine a templated nested class in the subclass?

Consider the following: template <typename T> class Base { public: template <typename U> class Nested { }; }; template <typename T> class Derived : public Base<T> { public: //How do we typedef of redefine Base<T>::Nested? using Base<T>::Nested; //This does not work using Base<T>::template<typename U> Nested; //C...

C++, what is a good way to hash array data?

hello I have a curious problem and I am brainstorming possible solutions. The problem is such: I have a number of inputs (up to several thousand different ones), which basically differ in two-three arrays (arrays are a different size generaly, from size one up to couple thousand elements long). the functions which process arrays take s...

Why is .NET faster than C++ in this case?

Make sure you run outside of the IDE. That is key. -edit- I LOVE SLaks comment. "The amount of misinformation in these answers is staggering." :D Calm down guys. Pretty much all of you were wrong. I DID make optimizations. It turns out whatever optimizations I made wasn't good enough. I ran the code in GCC using gettimeofday (I'll past...

c++ elevating privileges on an .exe using OpenProcess()

Hi, I have been reading some of the books by Hoglund and I thought I would have a 'go' at his 'simple debugger'... Anyway, I have been trying to use the line hProcess = OpenProcess(PROCESS_ALL_ACCESS | PROCESS_VM_OPERATION, 0, aPID); Every time I use it on a running process hProcess is being returned as NULL, why is this - the targe...

Read and write bytes from a file (c++)

I think I probably have to use an fstream object but i'm not sure how. Essentially I want to read in a file into a byte buffer, modify it, then rewrite these bytes to a file. So I just need to know how to do byte i/o. Thanks ...