c++

How to force the compiler to use explicit copy constructor?

Hi all I wrote a small test program with a sample class containing also self-defined constructor, destructor, copy constructor and assignment operator. I was surprised when I realized that the copy constructor was not called at all, even though I implemented functions with return values of my class and lines like Object o1; Object o2(o1...

Loading user profile from a service

In a service, I try to use the following code to launch a program : HANDLE hPipe; HANDLE hToken; PROFILEINFO stProfileInfo; char szUserName[64]; DWORD dwUserNameSize = 64; // Take the identity of the client ImpersonateNamedPipeClient(hPipe); // Retrieve the user name (DOMAIN\USER) GetUserNameEx(NameSamCompatible,szUserName,&dwUserName...

GotoBookmark tooo slow?

Hi, I'm fixing a C++ Builder 5 application and I have this code: void __fastcall TFPrincipal::DBGModuleStartDrag(TObject *Sender, TDragObject *&DragObject) { m_pParentNodesDragDrop = NULL; DragObject = NULL; bool bAbort = false; m_ListaModulosDragDrop->Clear(); m_ListaContenedoresDragDrop->Clear(); CInfoNode *pInfoN...

What do people mean when they say C++ has "undecidable grammar"?

What do people mean when they say this? What are the implications for programmers and compilers? ...

How should I correct this code that causes "value computed not used" warning?

I have an array of doubles and need to do a calculation on that array and then find the min and max value that results from that calculation. Here is basically what I have: double * array; double result; double myMin; double myMax; // Assume array is initialized properly... for (int i = 0; i < sizeOfArray; ++i) { result = transmog...

POSIX threads experience? (Or recommend better one)

I am looking for lightweight multi-threading framework for C++. I found POSIX Threads. Please, share you practical experience with POSIX threads: before I start with it I want to know its pros and cons from real people, not from wiki. If you practically compared it with anything (maybe, better), it would be interesting to know either. ...

Prefix search in a radix tree/patricia trie

I'm currently implementing a radix tree/patricia trie (whatever you want to call it). I want to use it for prefix searches in a dictionary on a severely underpowered piece of hardware. It's supposed to work more or less like auto-completion, i. e. showing a list of words that the typed prefix matches. My implementation is based on this ...

Boost linkage error in Eclipse

I've been banging my head fruitlessly against the wall attempting to include boost's thread functionality in my Eclipse C++ project on Ubuntu. Steps so far: Download boost from boost.org ./configure --with-libraries=system,thread make sudo make install sudo ldconfig -v In the eclipse project, set the include directory to: /usr/loc...

Programmatically get the cache line size?

Just want to document the answer to this specific question... a similar question (with potential answers was asked here) All platforms welcome, please specify the platform for your answer. ...

What does '?' do in C++?

int qempty(){ return(f==r)?1:0;} In the above snippet, what does "?" mean? What can we replace it with? ...

Passing Windows handle into an Unmanaged C++ dll

An unmanaged C++ dll has an exported function, that takes an int type as window hanlde void SetWindowHandle(int nHandle); else where in the unmanaged dll code the int is casted to HWNDand is used properly. And from the windows forms application, I set the handle as follows _hHandle = this->Handle.ToInt32(); m_pViewer->SetWindowHandl...

LoadLibrary fails: First chance exception 0xC0000139 (DLL Not Found) - How to debug?

I have a dll "mytest.dll" that when loaded via LoadLibrary(), returns NULL (and 127 as the GetLastError()). If I use DependencyWalker on "mytest.dll", it reports that it should load correctly and that all DLLs are found correctly. Running the profiler option of DependencyWalker on the host exe gives me this relevant section in the log:...

C++: How is it possible that reading data can affect memory?

I've been going deeper into C++ recently and my bugs seem to get complex. I have a vector of objects, each object contains a vector of floats. I decided I needed to create a further flat array containing all the float values of all objects in one. It's a little more complex than that but the gist of the problem is that as I loop throu...

List of study topics

I have experience developing MFC applications with C++ using Visual Studio 6.0. You can guess how long ago that was (hint: going on 10 years). I am trying to update my skills but a lot has changed. How would one go about bringing these skills up to date? ...

decimal places and Pow function in c++

Most likely a really simple question, please keep any answers easy to understand I'm still quite new at this: I'm making a little app, and I need to use powers for a couple of calculations. After a little research I found the pow function in cmath, and have had a play. In the end i came up with this snipped, which works: #include <iost...

Which are the implications of return a value as constant, reference and constant reference in C++ ?

Hello. I'm learning C++ and I'm still confused about this. What are the implications of return a value as constant, reference and constant reference in C++ ? For example: const int exampleOne(); int& exampleTwo(); const int& exampleThree(); ...

Testing the performance of a C++ app

I'm trying to find a way to test how long it takes a block of C++ code to run. I'm using it to compare the code with different algorithms and under different languages, so ideally I would like a time in seconds / milliseconds. In Java I'm using something like this: long startTime = System.currentTimeMillis(); function(); long stopTime...

How to parse kanji numeric characters using ICU?

I'm writing a function using ICU to parse an Unicode string which consists of kanji numeric character(s) and want to return the integer value of the string. "五" => 5 "三十一" => 31 "五千九百七十二" => 5972 I'm setting the locale to Locale::getJapan() and using the NumberFormat::parse() to parse the character string. However, whenever I pass...

Homebrew Chi-Squared Probability Function in C++

The following code of mine compute the confidence interval using Chi-square's 'quantile' and probability function from Boost. I am trying to implement this function as to avoid dependency to Boost. Is there any resource where can I find such implementation? #include <boost/math/distributions/chi_squared.hpp> #include <boost/cstdint.hpp...

Improving and publishing an application. Need some advice.

Hi, Last term (August - December 2008) me and some class mates wrote an application in C++. Nothing spectacular, it is an ORM for Sqlite3. We implemented some stuff like reflection to make it work and release the end user from the ugly stuff. Personally, i think we made a nice job, and that our ORM could actually be useful for someone (e...