c++

Event does not work after drag and drop operation

I developing some kind of builder for our project. I want to use both drag and drop support and context menu in my application. Currently I use drag and drop support but no luck with context menu. Below is my builders gui. Left side my gui is toolbox. I am draging and droping widgets to the right side(QGraphicsScene) and I also want to...

get weird cursor position

Ok so I'm working with vectors today yaya! well im also working with getcursorpos() and i get weird results. here is the code: VOID fRegularShot(HDC hdc, HWND hWnd) { Graphics graphics(hdc); Image shot(L"RegularShots.png"); long index=0; while(index<=(long)pRegularShots.size()) { index+=2; int x=pRegu...

runtime type comparison

Hi, I need to find the type of object pointed by pointer. Code is as below. //pWindow is pointer to either base Window object or derived Window objects like //Window_Derived. const char* windowName = typeid(*pWindow).name(); if(strcmp(windowName, typeid(Window).name()) == 0) { // ... } else if(strcmp(windowName, typeid(Window_Derived...

Object-Oriented Callbacks for C++?

Hi! Is there some library that allows me to easily and conveniently create Object-Oriented callbacks in c++? the language Eiffel for example has the concept of "agents" which more or less work like this: class Foo{ public: Bar* bar; Foo(){ bar = new Bar(); bar->publisher.extend(agent say(?,"Hi from Foo!", ?));...

Templated Matrix Class Not Generating Functions Correctly

Basically, I have a matrix class like this (with a lot of operator overloads and other functions removed): template < uint32 TRows, uint32 TCols > struct Matrix { float values[TRows][TCols]; inline explicit Matrix() { } inline Matrix<TRows - 1, TCols - 1> minor(const uint32 col, const uint32 row) { ...

should you be able to define a friend within a class?

the following code compiles fine under gcc: class vec3 { private: float data[3]; public: vec3(float x, float y, float z) { data[0] = x; data[1] = y; data[2] = z; } void operator =(const vec3 &v) { data[0] = v.data[0]; data[1] = v.data[1]; data[2] = v.data[2]; } friend vec3 operator *(float a...

Check Disk fullness

Possible Duplicate: How to determine how much free space on a drive in Qt? How can I check disk fullness with C++ using Qt ? Thanks a lot ...

C++ Style Coding

Hello, First off, I know this may be a very stupid question, so don't shoot me for asking it. I come from C++ background, and I love C++ to death, but now that I've been using C# for a while, I've grown to love C#. BUT, I miss the coding style of C++ and sometimes wish I could go back, but C# is just so time-saving now compared to C++ ...

How to display a Date value in Visual studio Debugger when it is a simple unsigned short

In our company we use ints to store Date values. The logic behind it is quite simple. The int contains the number of days since 1.1.1970. We have our own functions to convert these ints to strings at runtime. My problem is, that I haven't found a way to tell the debugger to display these values as Dates (strings). I only see 40345 and ...

Receiving assert failure on Reference Call

Hello, (Disclaimer: I have removed the Qt tag in case the problem is in my syntax / understanding of the references involved here) I have a foreach loop with an object Member. When I enumerate through the list and try to access a member field, the debugger stops and I get a message: Stopped: 'signal-received' - The assert failure is...

different code behaviour with and without debugger at C++ .net4

I have WPF application which was migrated from .net3.5 to .net4.0. This application uses an old one C++ library (as I understand this is mixed mode library, means managed-unmanaged). Library moved to .net4 environment with some strange bug which occurs on callback call: if (m_pCANCallback) m_pCANCallback(m_pCANCa...

how to know the existance of NAN value in a double variable ?

Hi, i have issue with comparing NAN value in C++, Visualstudio. I need to handle Division by Zero in my code. if i get division by zero, i want to assign NAN to the result. Check at later point of time, whether result has NAN. But NAN comparision is failing at later point of time, even though i assign quiet_Nan() as below. double d = st...

Is it possible to get the pointer the continous memory fragment in a std::vector<char> in C++?

I moved my code to use std::vector<char> instead of char *mem = malloc(...) but now I am facing a problem that I can only access the vector data through operator [] but not via a pointer. I can't write stuff like: std::vector<char> data; fill_data(data); char *ptr = data; Before I could do this: char *data = malloc(100); fill_data2(...

howto capture stack corruption on 64bit app?

my 64bit app (Windows) is having a crash. I have not been able to make anything by either code examination or by examining the state in debugger. (VS2008) with some instrumented code that performs periodic checks of the values object instance . This object that appears to be in an inconsistent state and generates an access violation whe...

C++ template arguments in constructor

Why doesn't this code compile? template <class T> class A { public: A(T t) : t_(t) {} private: T t_; }; int main() { A a(5.5); // A<double> a(5.5); // that's what i don't want to do } I want template arguments to be implicit. Like in this example: template<class T> T Foo(T t) { return t; } ...

At will scaling and rotation in a 2D space

Hi, I'm trying to write a graphical program in C++ with QT where users can scale and rotate objects with the mouse (just like inkscape or CorelDraw does), however after many months trying to make it happen I still cannot make it work. It currently works for example by just rotating or just scaling, but not when the user want to transfor...

Is there a muti index container for the harddisk storage rather than memory?

I need a muti index container based on red-black trees (something like boost::multi_index::multi_index_container) for the case of the harddisk storage. All data must be store on hard disk rather than in memory. Is there an open source container such that described conditions hold? Note. I use C++. ...

Difference between partition and remove functions in C++

What is the difference between the partition and remove functions in C++? THe remove doesn't actually remove any elements of the containers but puts the 'removed' elements at the beginning of the sequence of elements and partition does the same thing as well. ...

What is stack based class?

Possible Duplicate: How to prevent an object being created on the heap? Hi, I heard a concept called as stack based class. I.e. we can’t create instance of the class using new. I am hearing this for the first time. One way to implement this by private overloading of ‘new ’ operator. If anybody know details about the stack...

Templating boost::bind to automatically handle multiple arguments for member function

I have a class with an "Attach" function that accepts a function object and stores it into a collection. The class itself is templated on the function signature. Something like this: template<class Signature> class Event { public: void Attach(boost::function<Signature> signature) { MySignatures.push_back(signature); } private: ...