c++

How should I go about building a simple LR parser?

I am trying to build a simple LR parser for a type of template (configuration) file that will be used to generate some other files. I've read and read about LR parsers, but I just can't seem to understand it! I understand that there is a parse stack, a state stack and a parsing table. Tokens are read onto the parse stack, and when a rule...

replace _asm nop in 64-bit, VS2008, C++

How to replace _asm nop instructions in 64-bit. compiles and works in 32-bit. ...

Only include certain items in CComboBox type ahead?

I have a dropdown-list style CComboBox on a form. The nice thing about this style is it allows for type ahead--that is, you can type a character and it will jump to the first item in the list matching that character. However, there are certain items which need to be excluded from this behavior. How might this be accomplished? ...

HLSL and ID3DXFont/ID3DXSprite

I've started at the beginning, and my code will capably display the grand total of some text. I've been adding support for sprites. The trouble that I've run in to, is that it doesn't seem to recognize my HLSL. I set the technique, began it, began the pass, drew the sprites, flushed them, ended the pass, the technique. And D3D comes up w...

What is meant by Resource Acquisition is Initialization (RAiI)?

What is meant by Resource Acquisition is Initialization (RAiI)? www.technical-interview.com ...

Using expat to parse xml

I need to get attributes name and values of an xml file with many elements. what is the best way to capture the attribute values in a class? I have to following code for the startelement handler: start(void *data, const char *el, const char **attr) { int i; // Skip the ParameterList element if(strcmp(el, "ParameterList") == 0) ...

How to debug a strange memory leak ( C++ )

I'm writing a linux deamon and as for now it works pretty well, but it leaks memory ( and it's bad - after few hours it segfaults after using 60% of the system's memory). The strange thing is, that I'm using only new/delete operators and have a try/catch block around the main function, so it's not an exception thrown by new - it just seg...

C++: why can't we have references to references or array of references?

I noticed that there is no reference to reference but there is pointer to pointer, and also there is no an array of references but an array of pointers. Could anybody give me any reason? ...

Why do I get warning C4081 on this #pragma?

I am in the habit of removing all warning reported in my code. I just like a clean build if possible. I used #pragma comment(lib,"some.lib"); I get this warning: warning c4081: expected 'newline'; found ';' I am uncertain why that would create a warning. Could I get help on removing it? ...

How do I avoid name collision with macros defined in Windows header files?

I have some C++ code that includes a method called CreateDirectory(). Previously the code only used STL and Boost, but I recently had to include <windows.h> so I could look-up CSIDL_LOCAL_APPDATA. Now, this code: filesystem.CreateDirectory(p->Pathname()); // Actually create it... No longer compiles: error C2039: 'CreateDirectoryA'...

How do I layout my C++ program? (where should I put the .h and .cpp files?)

Currently, I program in Java and use Maven quite a bit. As so I've become accustom to the naming schemes and folder structures that I've used over the past 4 or 5 years. As I have recently started to learn C++, I'm realizing that I have no idea where to put all my files. Should I keep everything broken down by namespace, or by what ...

Is it possible to use CIN and QT ???

within Qt is it possible to use cin?? I can use cout but cannot find anywhere where it shows how to use ciin within a Qt Console application many thanks, gda2004 ...

issue with using std::copy

I am getting warning when using the std copy function. I have a byte array that I declare. byte *tstArray = new tstArray[length]; Then I have a couple other byte arrays that are declared and initialized with some hex values that i would like to use depending on some initial user input. I have a series of if statements that I use t...

Forward declaration of 'const struct list::SingleList' , Invalid use of incomplete type 'list::SingleList' (Compilation errors)

SingleList.h #include "ListBase.h" #include "DataNode.h" #include "SingleListIterator.h" namespace list { class SingleListIterator; class SingleList : public ListBase { private: DataNode *head; DataNode *tail; public: SingleList(); SingleList(const SingleList &...

Argument order for mixed const and non-const pass-by-reference

In keeping with the practice of using non-member functions where possible to improve encapsulation, I've written a number of classes that have declarations which look something like: void auxiliaryFunction( const Class& c, std::vector< double >& out); Its purpose is to do something with c's public member functions and ...

Is there a way to know if the user has enabled "single click to open an item" in the control panel?

My program needs to know when the user has enabled "Single-click to open an item (point to select)" in the folder options window in file explorer. I have a mouse aid program and I need to know what this setting is set to programmatically? Is this available in the registry or something? ...

Why does this program crash: passing of std::string between DLLs

Hello together. I have some trouble figuring out why the following crashes (MSVC9): //// the following compiles to A.dll with release runtime linked dynamically //A.h class A { __declspec(dllexport) std::string getString(); }; //A.cpp #include "A.h" std::string A::getString() { return "I am a string."; } //// the following compil...

How do you create a simple comment header template for all new classes in Visual C++ 2010?

This may be a duplicate, but I haven't found anything that answers it thus far. My company passed a resolution that all files need to have a boilerplate comment header, with file name and copyright date among other things. I was hoping there would be an easy way to just create a header template that is added to the top of every new cla...

64-bit version of Boost for 64-bit windows.

Is there a version of 64-bit Boost library for VS2008 ? Or do I have to compile one myself? if, so, does anyone have experience with it? ...

What should I know about multithreading and when to use it, mainly in c++

I have never come across multithreading but I hear about it everywhere. What should I know about it and when should I use it? I code mainly in c++. ...