c++

taking the address of a temporary object

§5.3.1 Unary operators, Section 3 The result of the unary & operator is a pointer to its operand. The operand shall be an lvalue or a qualified-id. What exactly does "shall be" mean in this context? Does it mean it's an error to take the address of a temporary? I was just wondering, because g++ only gives me a warning, whereas come...

how can i check file write permissions in C++ code?

In my C++ program, I want to make sure i can write info to a file. How can I perform this check? ...

How to get all the dates displayed in a QCalendarWidget

Hello, I am using a QCalendarWidget in my application, and I overloaded the updateCells method to put a red background on every dates which meet certain conditions. My problem is I don't know how to get the first date displayed in the calendar (not the first date in the month), and the last date displayed. Example: in february, the fir...

mapping user defined data type (VBA) to C++

Hi, Can somebody please tell me how to pass a VBA user defined type to a c++ (dll). I specially need to know how to handle string type of VBA in the dll. Thank You ...

quick vector initialization c++

Possible Duplicates: C++: Easiest way to initialize an STL vector with hardcoded elements Using STL Allocator with STL Vectors out of curiosity i want to know quick ways of initializing vectors i only know this double inputar[]={1,0,0,0}; vector<double> input(inputar,inputar+4); ...

C++ Inserting a class into a map container

I have a map in C++ and I wish to input my class as the value, and a string as the key. When I try to, I get an error 'Scene_Branding' : illegal use of this type as an expression I get an illegal use of this type as an expression, and I can't seem to find out why. Here is some code. string CurrentScene = "Scene_Branding"; map<string, ...

Read and parse line in C/C++; put tokens in an array or vector or similar structure

Hello everyone, I have to submit code to one of the problems in ACM IPC and, as you may know, the time counts a lot. So, I have to read efficiently an input like this: The first line will contain the sequence of integer values associated and the second line will contain the sequence of integer values associated with another sequence. E...

VS2008: Can I build a project with 2 CPP files of the same name in different folders?

Here is my folder structure: / | -- program.cpp -- utility.h -- utility.cpp | -- module/ | -- utility.h -- utility.cpp // Note that I have two files named utility.h and two named utility.cpp On building the project, I get a link error (LNK2028: unresolved token and so on...) saying that some symbols aren't defined. ...

Automatically adding Enter/Exit Function Logs to a Project

I have a 3rd party source code that I have to investigate. I want to see in what order the functions are called but I don't want to waste my time typing: printf("Entered into %s", __FUNCTION__) and printf("Exited from %s", __FUNCTION__) for each function, nor do I want to touch any source file. Do you have any suggestions? Is ther...

Pointer allocation vs normal declaration.

Hi, sometimes I see in various C++ programs, objects declared and used like so: object *obj = new object; obj->action(); obj->moreAction(); //etc... Is there any benefit of doing that, instead of simply doing: object obj; obj.action(); obj.moreAction(); //etc ...

Impersonate standard user

Hi I am trying to make a running process of mine which is elevated to restart explorer using the standard user token. What I'm doing is first I run the main process as an administrator, then I take a snapshot of the running: if (Process32First(hSnapshot,&pe32)) { do { if (!wcsicmp(pe32.szExeFile, L"expl...

stl hash_map - modifying key

I have a hash map defined as class KeyType { int key; mutable bool flag; KeyType(int key) : key(key), flag(false) {} void setFlag() const { flag = true; } }; struct KeyType_hasher { size_t operator()(const KeyType& s) const { return static_cast<size_t> key; } }; struct KeyType_equal { size_t operat...

Stencil Buffer Read/Write mask.

In Direct3D10 the Stencil Read/Write mask is a byte (from 0x00 to 0xFF) In Direct3D9 the Stencil Read/Write mask is a int (from 0x00000000 to 0xFFFFFFFF) The question is : How the stencil read/write mask in Direct3D10 relate to the Direct3D9 one? Direct3D10 | 0x00FFFFFF or Direct3D10 | 0xFFFFFF00 ? And another question : Why the Di...

Class definition and memory allocation

If definition stands for assigning memory. How come a class definition in C++ has no memory assigned until an object is instantiated. ...

Threaded rendering with NSOpenGLView

Hello, I have an old AGL-based OpenGL windowing system that I am updating to use NSOpenGLView. The engine using it needs to run in its own loop in a separate thread and I am having trouble getting that to work. With AGL, I created the context in the loop thread, so there was no issue, but I'm a little bit confused about the way to do th...

Problem with x64 application and ActiveX control

Hi, I have a small unmanaged c++ application, I'm trying to use CoCreateInstance(...) to create an instance of the "Adobe SVG PLayer" which is installed as an ActiveX control. When I compile and run my application under 32-bit configuration, it works fine, but when I compile under 64-bit configuration, my application fails to create the...

Specialization of 'template<class _Tp> struct std::less' in different namespace

I am specializing the 'less' (predicate) for a data type. The code looks like this: template<> struct std::less<DateTimeKey> { bool operator()(const DateTimeKey& k1, const DateTimeKey& k2) const { // Some code ... } } When compiling (g++ 4.4.1 on Ubuntu 9.10), I get the error: Specialization of 'template struct std::l...

libxml2 xmlChar* cast to char*

How would you convert / cast an xmlChar* to char* from the libxml2 library? Thanks. ...

Interesting Problem (Currency arbitrage)

Arbitrage is the process of using discrepancies in currency exchange values to earn profit. Consider a person who starts with some amount of currency X, goes through a series of exchanges and finally ends up with more amount of X(than he initially had). Given n currencies and a table (nxn) of exchange rates, devise an algorithm that a pe...

stable sorting QTreeWidgetItems in QTreeWidget?

Hi all, I have a list of QTreeWidgetItems (with children) in a QTreeWidget. I do not use a model for my data. From another window in my application the user can navigate thru the same set of data (viewed differently) and the QTreeWidget in the first window then highlights that specific row by setting the background colour. However, wh...