c++

How to get the cursor position

Hello, I want to know how to get the cursor position on Windows in c++, Reasons: I try to move the mouse position on X Y coordinate with the screen information e.g: i want to set the mouse position in the offset x:576 y:854 on the screen. The only method that I found for do that is: mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE|...

How To Shift Array Elements to right and replace the shifted index with string in Visual C++

VISUAL C++ Question Hi, I have array of 3 elements and I want to shift its elements to the right and replace the shifted index cell with "SHIFTED" string and this should loop until all the cells has "SHIFTED" string. For example: int a[x]={0,1,2}; Initial index and elements Order: [0]=0 [1]=1 [2]=2 should become in the: 1st l...

QTableView has unwanted checkboxes in every cell

I'm just getting started with Qt programming, and I'm trying to make a simple tabular data layout using a QTableView control with a model class of my own creation inheriting from QAbstractTableModel. For some reason, my table view ends up looking like this: What in the heck are those things that look like checkboxes (but don't do anyt...

Compile errors when trying to use list in C++

I'm trying to use list in c++, but I get the following error: 1>error C2143: syntax error : missing ';' before '<' 1>error C4430: missing type specifier int assumed. Note: C++ does not support default-int 1>error C2238: unexpected token(s) preceding ';' With the following code: #pragma once #include "Includes.h" class ...

Trying to do this homework assignment but I keep getting a compilation error.

This is only the first part of my homework, I've fixed all the other compilation errors but I keep getting this error, theres five. 1>\takehome\main.cpp(39) : error C2065: 'j' : undeclared identifier 1>\takehome\main.cpp(44) : error C2065: 'j' : undeclared identifier \takehome\main.cpp(45) : error C2065: 'j' : undeclared identifier \tak...

vertical text won't be bold in win32 GDI c++

I'm trying to draw vertical text in win32 GDI api. I call CreateFont() with 2700 for the angle and 900 for bold. logPxlY = ::GetDeviceCaps (c->_hdc, LOGPIXELSY); _hfont = ::CreateFont (-::MulDiv (point, logPxlY, 72), 0, angle, weight, 0, FALSE, FALSE, FALSE, 0, 0, 0, 0, FIXED_PITCH | FF_MODERN, face); where face is "Courier Ne...

I have a text-box and i want to enter a string in language A...

OK I will try to ask it again. I have a text-box and I want to enter a string in language A and send it to "google translate". After Google has translated it I want to take the new string(in language B) (after translation) and store it in some variable. I hope this time it is more clear. How I do it?? ...

How to design a class appropriate for millions of allocations?

If I want to allocate millions of objects of a class Foo, and I want to be memory- and time-efficient, how should I design the Foo class? Obviously, Foo should not contain much member data. Also, I guess, it should not use virtual functions? And how costly is it for Foo to derive from a Base class? And from several Base classes? ...

Iphone, callback and objective c

Hi, I am using a c++ library using callback to inform about the progress of an operation. Everything is working fine except this: I need to have a function in my controller to be use as a c++ callback function. I've tried a lot of things but none of them are working. Do you know how we can manage this kind of thing? Thanks :) ...

C++: has not been declared error

Hi folks, I'm trying to implement a linked list but get a intSLLst.cpp:38: error: ‘intSLList’ has not been declared error when compiling. intSLList looks like it's been declared to me though so I'm really confused. intSLLst.cpp #include <iostream> #include "intSLLst.h" int intSLList::deleteFromHead(){ } int main(){ } intSLLst....

How to prevent double inclusion of a .lib when inheriting dependencies?

Hello, I'm working to a Visual C++ 2008 project which needs two libraries (A and B), both of them are compiled using a a particular .lib (C). When I compile my project I'm asked for C again, and thus I specify it in the additional libraries. Then everything goes ok until the linking phase, where I get errors for external symbols which ar...

How to get the Executable name of a window

Hi, I try to get the name of executable name of all of my launched windows and my problem is that: I use the method UINT GetWindowModuleFileName( HWND hwnd, LPTSTR lpszFileName, UINT cchFileNameMax); And I don't understand why it doesn't work. Data which I have about a window are: -HWND AND PROCESSID The error is: e.g: HWND...

Bit packing of array of integers

I have an array of integers, lets assume they are of type int64_t. Now, I know that only every first n bits of every integer are meaningful (that is, I know that they are limited by some bounds). What is the most efficient way to convert the array in the way that all unnecessary space is removed (i.e. I have the first integer at a[0], ...

How to convert a double to a string without using the CRT

Hi everybody. My question has no practical application. I'm just interested. Suppose, I have a double value and I want to obtain its string representation similarly to the printf function. How would I do that without the C runtime library? Let's suppose I'm on the x86 architecture. ...

Variable accessible to all instances of a class

Let's say I have a lookup table which I'd like to make accessible to all instances of Foo. Should I make the table private static? If not, what should I do? Basically I want a way to save just one copy of the table (so it doesn't consume extra memory for each instance of Foo) and have it available privately to all instances of Foo. ...

Iterator from both ends of a Vector

Hi, I have a vector of IntRect: vector. How can I iterate from both ends of the list and stop the iterator when the iterator intersects? vector<IntRect>::iterator itr = myVector.begin(); vector<IntRect>::reverse_iterator revItr.rbegin(); for (; /*check itr and revItr does not intersect, and itr and revItr do not end */ ; ++itr, +...

How to have a policy class implement a virtual function?

I'm trying to design a policy-based class, where a certain interface is implemented by the policy itself, so the class derives from the policy, which itself is a template (I got this kind of thinking from Alexandrescu's book): #include <iostream> #include <vector> class TestInterface { public: virtual void test() = 0; }; class TestI...

c++ use of winmain()

Hi, I just started learning programming for windows in c++. I had this crazy image, that win32 programming is based on calling windows functions and sending parameters to and from them. Like, when you want to create window, you call some win32 function that handles windows GUI and say "Hi, please, create me new window, 100 x 100 px, with...

Undefined, unspecified and implementation-defined behavior

What is the difference between these three? ...

Calling handwritten CUDA kernel with thrust

Hi, since i needed to sort large arrays of numbers with CUDA, i came along with using thrust. So far, so good...but what when i want to call a "handwritten" kernel, having a thrust::host_vector containing the data? My approach was (backcopy is missing): int CUDA_CountAndAdd_Kernel(thrust::host_vector<float> *samples, thrust::host_vect...