c++

Refactoring a "dumb" function into generic STL-style with iterators to containers

I've managed to wrap my head around some of C++'s functional capacities (for_each, mapping functions, using iterators...) but the construction of the templates and function argument lists for taking in generic containers and iterators still eludes me. I have a practical example I'm hoping someone can illustrate for me: Take the followin...

How to print subscripts/superscripts on the screen in C++ ?

Is it possible to print subscripts/superscripts ? for exmeple like that : x² what are fuctions allow to do that ? ...

Boost in Visual Studio 2010, IntelliSense error

Hello, I would like to see if you could orient me. It happens that I compiled and referenced the boost libraries in order to use them with Visual Studio 2010. When building my test project I get these two IntelliSense errors 1 IntelliSense: #error directive: "Macro BOOST_LIB_NAME not set (internal error)" c:\boost_1_43_0\boost\confi...

Hello world/Console Project in Visual Studio 2008 64 bit

So I am trying to run console 64 bit Hello World program. I have Windows 7 Enterprise x64 bit version. I have installed Visual Studio 2008 and have added all of components needed for 64 bit. I want to create simple console application. It turns out to be a problem. I have simple standard hello world project. I have created it using...

Is there an alternative to Pidgin, but with less restrictive licensing?

Recently came across pidgin. Its great, and does what I want, but I am not too keen on the GPL license. Other any alternatives, with less restrictive licenses? I would prefer the library to be C or C++, as I am most familiar with those languages, but a an IM library implemented in python would be interesting too. ...

How to force inclusion of an object file in a static library when linking into executable?

I have a C++ project that due to its directory structure is set up as a static library A, which is linked into shared library B, which is linked into executable C. (This is a cross-platform project using CMake, so on Windows we get A.lib, B.dll, and C.exe, and on Linux we get libA.a, libB.so, and C.) Library A has an init function (A_i...

Impersonate SYSTEM (or equivalent) from Administrator Account

This question is a follow up and continuation of this question about a Privilege problem I'm dealing with currently. Problem Summary: I'm running a program under a Domain Administrator account that does not have Debug programs (SeDebugPrivilege) privilege, but I need it on the local machine. Klugey Solution: The program can install i...

QTextDocument eats multiple whitespaces

There is a Qt/C++ code: #include <QtCore/QCoreApplication> #include <QtGui/QTextDocument> #include <QByteArray> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QTextDocument *doc = new QTextDocument(); qDebug() << " === Document was: === "; qDebug() << doc->toHtml(QByteArray()); ...

Code to strip diacritical marks using ICU

Can somebody please provide some sample code to strip diacritical marks (i.e., replace characters having accents, umlauts, etc., with their unaccented, unumlauted, etc., character equivalents, e.g., every accented é would become a plain ASCII e) from a UnicodeString using the ICU library in C++? E.g.: UnicodeString strip_diacritics( Un...

CSS in Qt Creator

I can't find anything on this topic, is it possible to use CSS files in Qt or do I have to use setStyleSheet on every element I want to style? I can't say its very maintainable if I have to write all the styles in quotes. ...

C++ enum casting and templates

I get the following error with VS2008: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast) When casting a down casting a ClassA to ClassA_1 and ClassA_1 is a templated class that received an enum for parameter such as: THIS IS AN EDIT OF MY QUESTION WHICH RE-USE AN ANSWER BELOW BU...

Making a window a desktop in XLib/Qt

I am trying to write a simple program to act as my desktop background in Qt, I have made it all work fine apart from making it a Desktop Widget. I have no idea on how to do this, I don't mind using XLib or Qt for doing this, but if anyone has some suggestions I would be very happy. ...

C++ Dynamic Allocation Mismatch: Is this problematic?

I have been assigned to work on some legacy C++ code in MFC. One of the things I am finding all over the place are allocations like the following: struct Point { float x,y,z; }; ... void someFunc( void ) { int numPoints = ...; Point* pArray = (Point*)new BYTE[ numPoints * sizeof(Point) ]; ... //do some stuff with points...

Keeping a window always on top -- including menus (win32)

I would like to have a layered window that is always-on-top, which I can accomplish, but there are certain screen elements that still get drawn over it, such as menus (including the start menu). Is there any way to make a window or child window of my application have a high enough top-ness property that it will draw over another applic...

How to display scrollbar for a list view whose contents keep changing?

I have a ListView-like control that displays a list of items of various heights. The contents of the list, and the heights of the items can change – a background thread is populating the list and calculating the layout of each item, possibly even while the user is scrolling the content. Which brings me to my question: How do I display ...

how do i set up an SMS server?

just like google as the number GOOGL (46645) i would like to also set up a server like this that will have the ability to receive text messages. how do i do this>??> ...

How do I get the number of visible characters from a UTF-8 encoded char*?

I have a UTF-8 encoded char*. Is there a standard function to calculate the number of visible characters represented by the byte array? I'm on Red Hat (RHEL 5). ...

Get image data for Direct3d rendering stream

I would like to get at the raw image data, as in a pointed to a byte array or something like that, of the image output from a direct3d app without actually rendering it to the monitor. I need to do this so that I can render direct3d as a directshow source filter Visual studio 2008 c++ ...

program crashes at CIN input | C++

hello okay, so i made a DOS program however my game always crashes on my second time running to the cin function. #include <iostream> #include <string> #include <ctime> #include <cstdlib> using namespace std; //call functions int create_enemyHP (int a); int create_enemyAtk (int a); int find_Enemy(int a); int create_enemyDef (int a); ...

[C++] Static Class Data Members and Constructors

How do I access a static member in a class with all static methods? I want to have a group of related functions but also have some important data members initialized before any of these functions are called. I thought a class with only static members would be the way to go. Compiler in VS2008 doesn't like me trying to access "a". Sure...