c++

Multiple key map in c++

Hi, I'm wondering if any of you know of a c++ associative map container type which I can perform multiple key lookups on. The map needs to have constant time lookups but I don't care if it's ordered or unordered. It just needs to be fast. For example, I want to store a bunch of std::vector objects in a map with an integer and a void* as...

Visual Studio: Link executable

Lets say I have: a static library project called "LIB" a application project called "LIBAPP" a application project called "APP" a application project called "APPTEST" When i add "LIB" to LIBAPP Project Dependencies, Visual Studio automatically links "LIBAPP" against LIB. But when i add APP to APPTEST Project Dependencies, it doesnt....

extern "C" char** environ - Windows - C++/CLI

I have some old linux code I'm trying to port to Windows. When I first built it as a straight native DLL, I go no issues with this piece of code, but when I tried making it a mixed-mode C++/CLI DLL, I got an unresolved external object error on this: extern "C" char** environ; Why would this work for native and not CLI? Any idea how t...

Template debugging in C++

Hi All, I have a template class that is: template <class identifier,class registeredObject> class FxPairRegistry : public FxRegistry<pair<identifier,registeredObject> > { public: registeredObject GetEntry(identifier, FxBool assertValue = true); void RegisterInOrder(const pair<identifier,registeredObject> &ob); typedef typename ...

'strcpy' error and warning

I'm getting a 'strcpy' error and warning for the following lines: _tcscpy(strCommandLine,_T("MyProgram.exe /param1")); _tcscpy(strApplicationName,_T("MyProgram.exe")); Not sure why I'm getting a 'strcpy' error or warning since I'm not using 'strcpy'. The only lines related to this is: LPCTSTR strApplicationName; LPTSTR strCommandLin...

how can i store more than just one letter in a variable?

with char i get this error: .\main.cpp(6) : error C2015: too many characters in constant ...

Strange behavior of std::cout &operator<<...

Hey ppl, I came across something weird today, and I was wondering if any of you here could explain what's happening... Here's a sample: #include <iostream> #include <cassert> using namespace std; #define REQUIRE_STRING(s) assert(s != 0) #define REQUIRE_STRING_LEN(s, n) assert(s != 0 || n == 0) class String { public: ...

How to change subnet mask and DHCP enabled flag in C++ and Windows XP

Does anyone know how to change the subnet mask and the DHCP enabled flag on Windows XP / Vista / 7 from a C++ program? The Windows API has a GetAdaptersInfo() routine which will give you that information, but I need the counterpart SetAdaptersInfo() which doesn't seem to exist. I've looked all over MSDN and the web and don't see how to...

What's the difference between CArray<int, int> and CArray<int, int&> ?

Same for CMap, CList, and pretty much everything that uses templates (I guess). I find it a bit hard to understand when to use which. It's true that for classes and such, the <class, class&> form is usually what you want, but for basic types like int, float, etc., which form is preferred? ...

Release edit in QTableWidget Cell

Basically I am trying to give the enter key the same functionality as the return key has when editing a cell in a qtablewidget. If editing a cell and enter is pressed I want it to jump out of editing that cell just like return does. It feels like I've literally tried everything. I've even tried passing a return press event to qcoreapplic...

DWORD to bytes using bitwise shift operators

I can't get it to work correctly. #include <windows.h> int main() { DWORD i = 6521; BYTE first = i >> 32; BYTE second = i >> 24; BYTE third = i >> 16; BYTE fourth = i >> 8; i = (((DWORD)fourth) << 24) | (((DWORD)third) << 16) | (((DWORD)second) << 8) | first; } ...

Do Destructors Have Names According To The Standard?

Do class destructors have names in the pedantic sense according to the Standard? Recall that constructors explicitly do not have names: 12.1.1 : Constructors do not have names. A special declarator syntax using an optional sequence of function-specifiers (7.1.2) followed by the constructor’s class name followed by a param...

QExplicitlySharedPointer and inheritance

What is the best way to use QExplicitlySharedPointer and inherited classes. I would like when the BaseClass exits on it's own to have a my d pointer be QExplicitlySharedPointer<BaseClassPrivate> and when I have a Derived class on top of this base class I'd like to have d be a QExplicitlySharedPointer<DerivedClassPrivate>. I tried makin...

Boost graph: Apply algorithms considering a specific edge subset.

Hi, I've got a huge graph with typed edge (i.e. edge with a type property). Say typedef adjacency_list<vecS, vecS, vertex_prop, edge_prop> Graph; The "type" of the edge is a member of edge_prop and has a value in {A,B,C,D}, I'd like to run the breadth first search algorithm considering only edges of type A or B. How would you do ...

problem with QDataStream & QDataStream::operator>> ( char *& s )

QFile msnLogFile(item->data(Qt::UserRole).toString()); QDataStream logDataStream; if(msnLogFile.exists()){ msnLogFile.open(QIODevice::ReadOnly); logDataStream.setDevice(&msnLogFile); QByteArray logBlock; logDataStream >> logBlock; } This code doesnt work. The QByte that results is empty. Same...

Prototyping Qt/C++ in Python

I want to write a C++ application with Qt, but build a prototype first using Python and then gradually replace the Python code with C++. Is this the right approach, and what tools (bindings, binding generators, IDE) should I use? Ideally, everything should be available in the Ubuntu repositories so I wouldn't have to worry about incompa...

Iterator failure while moving over equal_range in Boost MultiIndex container

I'm making some mistake with my iterators, but I can't see it yet. I have a Boost MultiIndex container, HostContainer hmap, whose elements are boost::shared_ptr to members of class Host. All the indices work on member functions of class Host. The third index is by Host::getHousehold(), where the household member variable is an int. Be...

array, I/O file and standard deviation (c++)

double s_deviation(double data[],int cnt, double mean) { int i; double sum= 0; double sdeviation; double x; //x = mean(billy,a_size); for(i=0; i<cnt; i++) { sum += ((data[i]) - (mean)); } sdeviation = sqrt(sum/((double)cnt)); return sdeviation; } Wh...

how to create a registry key without using system() in c/c++??

how to create a registry key without using system()/.bat/.reg in c/c++?? ...

C++: Vector of objects vs. vector of pointers to new objects?

Hello, I am seeking to improve my C++ skills by writing a sample software renderer. It takes objects consisting of points in a 3d space and maps them to a 2d viewport and draws circles of varying size for each point in view. Which is better: class World{ vector<ObjectBaseClass> object_list; public: void generate(){ objec...