c++

How to create a Visual Studio 2008 C++ project template?

I've used the "Export Template" feature numerous times for C#, ASP.NET, WinForms, etc. projects. Today I tried to do it for a C++ project and noticed "Export Template" was grayed out in the File-menu. Is it not possible to create C++ template projects in VS 2008 ? ...

Generating n-digit numbers sequenced by sum of individual digits (without recursion)

I'm looking to generate all possible values of n-digit number, in the following order, where the sequence is dictated by the sum of the individual digits. For example, with n = 3: 111 sum = 3 112 sum = 4 121 211 122 sum = 5 212 221 113 131 311 114 sum = 6 141 411 ::: 999 sum = 27 The order within the sum group is ...

Should I use a const reference or a boost::shared_ptr?

Hi, I have created some C++ classes to model a Solitaire game as a learning exercise. I have classes for the SolitaireGame, a CardStack (one of the 10 piles of cards on the board ) and a Card. My current model states that the SolitaireGame owns a vector of 104 Card objects - which I call the 'shoe'. The SolitaireGame also keeps track ...

System-V message-queue PHP C++

I am wondering what are the limitation of System-V message queue i.e. Maximum queue size, maximum size per item etc. As I am working on integration of C++ with my PHP scripts and have very large amount of data which will be pushed into queue from php and C++ process will read that data on the other end. I have devised an strategy in whi...

Is it possible to set an application's windows compatibility mode at run-time?

We are using a 3rd party library that sometimes does not work correctly on Win7. WE know how to configure this at installation time, but we'd also like to consider setting it at run time. Is this possible, or does that context have to be set prior to launch? (I think there is a slim to none chance, but figured I would ask anyway) (C+...

boost bind compilation error

class A { bool OutofRange(string& a, string& b, string c); void Get(vector <string>& str, string& a, string& b); } void A::Get(vector <string>& str, string& a, string& b) { str.erase( std::remove_if (str.begin(), str.end(), BOOST_BIND(&A::OutOfRange, a, b, _1)), str.end() ); } I am getting ...

Is there a better way? While loops and continues

There are many functions within the code I am maintaining which have what could be described as boilerplate heavy. Here is the boilerplate pattern which is repeated ad nausea throughout the application when handling DB I/O with a cursor: if( !RowValue( row, m_InferredTable->YearColumn(), m_InferredTable->YearName(), m_InferredTable->Ta...

Fill the holes in OpenCV

I have an edge map extracted from edge detection module in OpenCV (canny edge detection). What I want to do is to fill the holes in the edge map. I am using C++, and OpenCV libraries. In OpenCV there is a cvFloodFill() function, and it will fill the holes with a seed (with one of the location to start flooding). However, I am trying to...

C++ unresolved symbols

Hey I'm getting an unresolved symbol error at linking in my proj. Im linking to an external library, and yes i have set up the configuration correctly, but when in Debug it outputs the following error for every class in the external library: error LNK2001: unresolved external symbol __CAP_EXIT_Function The proj uses the same runtime ...

First chance exception - long at memory location?

What is this and how can I handle/fix it? First-chance exception at 0x756fb727 in Program.exe: Microsoft C++ exception: long at memory location 0x0018f7a4. I am getting about a thousand of these each time I run my application. How can I track this down and fix it/ ...

Lisp as a Scripting Language in a C++ app...

Hey, I've been looking at the possibility of adding a scripting language into my framework and I heard about Lisp and thought I would give it a go. Is there a VM for Lisp like Lua and Python or am I in the wrong mindset. I found CLISP here, http://clisp.cons.org/, but am not sure if this is what I am looking for. Can anyone point me in ...

Using libtool to load a duplicate function name from a shared library

I'm trying to create a 'debug' shared library (i.e., .so or .dll file) that calls another 'real' shared library that has the same C API as the debug library (in this case, to emulate the PKCS#11 API). However, I'm running into trouble where the link map of the debug library is colliding with that of the real library and causing the debu...

Coding practices in C++, what is your pick and why?

I have a big object say MyApplicationContext which keeps information about MyApplication such as name, path, loginInformation, description, details and others.. //MyApplicationCtx class MyApplicationCtx{ // .... private: std::string name; std::string path; std::string desciption; struct loginI...

Can I put try / catch around an OS API that crashes?

I use a Windows OS library to manipulate image files. Sometimes it crashes deep inside it for no apparent reason—all the inputs are reasonable and its not a threading issue. The crash is memory A/V. So, what are the down sides to something like this: try { pFoo = OsAPIThatCrashes(); } catch { pFoo = NULL; } Will that even work?...

get number of CPUs in C++ MFC application

Hi! I write a little raytracer and i'd like to query how many cpu cores (or virtual cpu cores if the cpu uses hyperthreading) the current computer offers, such that i can instanciate as many threads to get better parallel rendering. How can I do that using C++? thanks! ...

C++ Composite Template Class Factory

Is it possible to make a composite template class factory without manually specifying all of the combinations? What I mean is if I have these classes: class CompositeBase {}; template< typename C1, typename C2, typename C3 > class Composite : public CompositeBase { private: C1 component1; C2 component2; C3 component3; }; ...

Is this a design flaw?

Consider two classes class A{ public: A(){ } ~A(){ } }; class AImpl : public A{ public: AImpl(){ a = new AInternal(); } AImpl(AInternal *a){ this->_a = a; } ~AImpl(){ if(a){ delete a; ...

In Place rotation C++ Practice

Hello, I have a working rotating function going for my "items" int array. The code below gets it done, except that im transferring values out unnecessarily. Im trying to acheive the "inplace" rotation. What I mean by that is where the ptrs would increment or decrement instead of grabbing values out of the array..By which I need to "up" ...

How stl vector gives random access

Hello Gurus, Yesterday evening I was using std::vector for my work, and this question popped into my mind: how does vector gives random access? I tried to look into code but was unsuccessful. Can anyone give some pointers? Thanks, Arun ...

I'm building a touch-screen application for a mobile device. What C++ toolkit should I use?

Building a touch-screen app for a mobile device, around the size of a book. What C++ toolkit should I use? I was thinking about Qt, or gtkmm with hildon. Thanks! ...