c++

C++ class in Cocoa

Any ideas why Xcode wont let me define a c++ class in my cocoa project? I am trying to use a C++ class in my cocoa project but I am getting build errors just creating the c++ header file. class SomeClass{ public: int count; }; Expected '=', ',', ';', 'asm' or 'attribute' before 'SomeClass' in ..... If I remove all code from the...

How to know if a QLineEdit got focus ?

I want to be able to know if in the QLineEdit it was a click. So I guess I should reimplement the following function(??): void QLineEdit::focusInEvent ( QFocusEvent * e ) [virtual protected] How I should do that? Also, please tell me how to use focusInEvent() function in order to know if QLineEdit myEdit; object got focus. EDIT: H...

C++ interview question involving class pointers

Lets say there is a base class pointer which is pointing to a base class object: baseclass *bptr; bptr= new baseclass; now if i do bptr= new derived; what is the problem here? ...

How to create combobox with bitmaps in Win32 ?

Hi ! I wanted to create a custom combo box like this (as in MS Word), Are there any Win32 API calls (I can't use MFC) to get this job done, (like ChooseColor() or ChooseFont()? If there aren't any, can anyone please tell me how to do this? Thanks you. Regards, EDIT: Creating the Owner-Drawn Dialog Box!! Is this the only way ? http:...

hash_map and stdext:: hash_map?

Under the visual C++, we have " hash_map" and "hash_set". In g++, we have " stdext::hash_map" and " stdext::hash_set". Is there any difference in terms of their respective performance or other factors? ...

C++ function object terminology functor, deltor, comparator, etc..

Is there a commonly accepted terminology for various types for common functors? For instance I found myself naturally using comparator for comparison functors like this: struct ciLessLibC : public std::binary_function<std::string, std::string, bool> { bool operator()(const std::string &lhs, const std::string &rhs) const { r...

GUI for server-client program

I am making a server-client application in c++. In this i am also using shared memory & file read-write operations. my program is completely ready & i now wants to make a gui for it. someone suggested me to go for QT4, but when i tried it, i found i have to re-write 80% of the code because QT has got its own classes & variable. i don't w...

Using IOCTL_MOUNTMGR_QUERY_POINTS

Dear all, I am not able to know how to use the IOCTL_MOUNTMGR_QUERY_POINTS . I have searched the internet and found some sample code to try with. but i am not sure whether its correct or not.... can you please let me know how to use the IOCTL_MOUNTMGR_QUERY_POINTS to get the drive letter Thank you for your time below is my source c...

Compilation errors calling find_if using a functor

We are having a bit of trouble using find_if to search a vector of pairs for an entry in which the first element of the pair matches a particular value. To make this work, we have defined a trivial functor whose operator() takes a pair as input and compares the first entry against a string. Unfortunately, when we actually add a call to...

DirectMusic, including <dmusici.h>

The problem is: When I include , I've got follow errors: dmdls.h:81: error: declaration of `WLOOP _DMUS_REGION::WLOOP[1]' dls1.h:264: error: changes meaning of WLOOP' fromtypedef struct _rloop WLOOP' An example: using namespace std; #include <d3d9.h> #include <dmusici.h> int main() { return 0; } ...

Auto generating sequence diagram for C++ code linux environment

Are there any eclipse plugin available to auto generate sequence diagram for C++ code running in the linux environment? Please let me know the details. Thanks. ...

Context Menu event with QGraphicsWidget

In my application I subclass QGraphicsWidget In paint I am drawing a line with pen width 4. I reimplemented boundingRect() and shape(). But I can't catch context menu event every time I click right mouse button. What is the problem.(Pen Width ? ) //Sample code for boundingRect() and shape() QRectF boundingRect() const { qreal r...

How to call operator<< on "this" in a descendant of std::stringstream?

class mystream : public std::stringstream { public: void write_something() { this << "something"; } }; This results in the following two compile errors on VC++10: error C2297: '<<' : illegal, right operand has type 'const char [10]' error C2296: '<<' : illegal, left operand has type 'mystream *const ' Judging fro...

GetAdaptersInfo (c++)function not working on vista and windows 7

i am using GetAdaptersInfo on windows xp to retrieve mac address.its working well on xp but neither on vista nor on windows 7. Is GetAdaptersInfo supported by windows 7 and vista. if no what api should i use to get mac address ...

How do I refactor code into a subroutine but allow for early exit?

There's a really obvious refactoring opportunity in this (working) code. bool Translations::compatibleNICodes(const Rule& rule, const std::vector<std::string>& nicodes) { bool included = false; // Loop through the ni codes. for(std::vector<std::string>::const_iterator iter = nicodes.beg...

Can I disable min, max in STL?

Hi, I use one library which is very important and untouchable. The problem is that library declare min, max function, so when I include STL header in project, they conflict. I want to disable min, max function in STL (like #define NOMNMAX) if I could. If I can't, what would be solution? Important : Sorry, It's not Macro. Two functions a...

Copy binary image data into a string

I need to send image data over network using HttpSendRequest POST request. For this purpose I am creating a string , adding some parameters to string, then I need to add raw image data. Now I would like to know how can I send the image in post request. ...

Why c++ is called an object oriented programming language?

Why c++ is called an object oriented programming language? ...

Embedded QGraphicsView do not hide after Dialog closes

I call a QDialog in to modes, showNormal and showFullscreen. In normal mode all works fine. With a Keyevent the Dialog closes as expected. In Fullscreen, after a keyevent the Dialog closes, but the QGraphicsView will stay on top. All things i've tried (like closing/updating the view) failed. the View sta on top. view = new QGraphicsView...

Qt - A login dialog

I want to create a login dialog by inheriting QDialog. I put in subclass named LoginDialog 2 QLineEdits: for login for password. I want to be able to warn the user with a message if the caps lock is ON while he will start to fill passwordLineEdit. Suppose I have a function that tells the current state of CapsLock button. So I want t...