c++

How can a member know in what class instance it is constructed?

class C { public T x; }; Is there an elegant way for the constructor of x to know implicitly in what instance of C it is constructing? I've implemented such behavior with some dirty inelegant machinery. I need this for my sqlite3 wrapper. I don't like all wrappers I've seen, their API IMO ugly and inconvenient. I wa...

Warnings using format strings with sprintf() in C++

Compiling this lines long int sz; char tmpret[128]; //take substring of c, translate in c string, convert to int, //and multiply with 1024 sz=atoi(c.substr(0,pos).c_str())*1024; snprintf(tmpret,128,"%l",sz); I read two warning on snprintf line: warning: conversion lacks type at end of format warning: too ...

How to find out if a pointer is on the stack on PC/Visual C++

[This is for PC/Visual C++ specifically (although any other answers would be quite illuminating :))] How can you tell if a pointer comes from an object in the stack? For example: int g_n = 0; void F() { int *pA = &s_n; ASSERT_IS_POINTER_ON_STACK(pA); int i = 0; int *pB = &i; ASSERT_IS_POINTER_ON_STACK(pB); } so o...

Is there a tutorial on C++ programming in Visual Studio 2008?

Can anyone link me to a decent c++ tutorial that's actually currently in date? Almost everything I find applies to 2005 and the code examples are riddled with errors which won't run in my 2008 version of the visual compiler. ...

C++0x - When?

When will C++0x be released? Anyone here know anything? ...

Simple Variables in Java & C++

I saw this sentence in some matrials: "In Java, simple data types such as int and char operate just as in C." I am wondering that actually they are different in Java & C++? In C++, simple variables like the primitives in Java are assigned a memory address as well, so these primitive types in C++ can have a pointer as well. However pri...

How to insert a null value with Qt?

Hello everybody! Tip me plase, how to insert a null value into table using Trolltech Qt 4.x SQL classes? QSqlQuery, I guess, or something else from QtNetwork. As analog of it, in .NET there is the System.DbNull class, which represents sql NULL. And what type should I use for some object's property, that can hold both null-value and QSt...

What are some reasons I might be receiving this "Symbol not defined" error in Visual Studio 2005 (screenshot included)

When debugging my VS2005 project, I get the following error when I attempt to step into the function that returns the vScenarioDescriptions local variable it's struggling with... As I continue to walk through the code and step into functions, it appears I'm getting this error other local variables as well. Any ideas? Thanks in advan...

Extracting individual digits from a float

I have been banging my head on this one all day. The C++ project I am currently working on has a requirement to display an editable value. The currently selected digit displays the incremented value above and decremented value below for said digit. It is useful to be able to reference the editable value as both a number and collection...

How Can I Create Rounded Rectangle Buttons in WM6?

Yes, like those pretty buttons on the iPhone. ;) I've been searching and reading for days now and everytime I find something that will get me close (like CreateRoundRectRgn), it blows up because Windows Mobile 6 GDI+ doesn't support it. I can do the whole owner draw thing and such. But how do I curve those hard corners and reshape a...

c++ modify resources at runtime

Is it possible to edit resources for an executable at runtime programmatically? If so, how? If not, is there another program that can easily be used to modify resources? Thanks, Derek. ...

OpenCV Sample Program lkdemo

Hi, reference, OpenCv\samples\c\lkdemo.c Anybody know what does the following snippet of codes does ? Code extracted from lkdemo.c for( i = k = 0; i < count; i++ ) { if( add_remove_pt ) { double dx = pt.x - points[1][i].x; double dy = pt.y - points[...

Can I get the file info which changes in a specified directory using FindFirstChangeNotification and FindNextChangeNofication instead of ReadDirectoryChangesW?

I want to monitor upon a specified directory and if there's any file or subdirectory changes, I can be notified. I realize the function with the following simple code segment: UINT myThreadFunc(LPVOID pParam) { int changeCount = 0; while(true) { HANDLE changeHandle = FindFirstChangeNotification(L"C:\\", TRUE, FILE_NOTIFY_CHANGE_...

How can I add very large numbers in C++?

How can I add very large numbers in C++? ...

Asynchronous ReadDirectoryChangesW()?

I want to monitor the modifications in a specified directory, and retrieve the exact change information. So I've decided to use the ReadDirectoryChangesW() function. But I want to use it asynchronously, which means I don't want my worker thread to be blocked if there's no changes in the directory. How can I do this? Thank you! ...

How to include sub-directories in Visual Studio?

Hi I have to include many header files, which are in different sub-directories. Is there a way in Visual Studio (I am using 2005 edition) to set one include path that Visual Studio will search also the sub-directories for header files? ...

What is the C++ equivalent to GetObject in JavaScript and VBScript?

What is the C++ equivalent to GetObject in JavaScript and VBScript? The closest match I found to my question is: http://codewiz51.blogspot.com/2008/06/vb-script-getobject-c-api-cogetobject.html However the sample use an unexisting interface and asking for the IUnknown returns null. Did someone have an example that works? ...

Looking for OSS for OSI Layer 2 Traffic Generator

I am looking for layer 2 traffic generator [open source]. Some OSS using winpcap or libpcap. Thanks a lot. ...

::FindWindow fails from Service application

Windows API ::FindWindow function fails when called from Service application. GetLastError() also returns 0 (success?). Is this some privilege\access right problem? Do you think it's design problem and I should use another IPC method? ...

using GDAL/OGR api to read vector data (shapefile)--How?

Hi, I am working on an application that involves some gis stuff. There would be some .shp files to be read and plotted onto an opengl screen. The current opengl screen is using the orthographic projection as set from glOrtho()..and is already displaying a map using coordinates from a simple text file.. now the map to be plotted is to b...