c++

GCC virtual memory exhausted: Permission denied

I'm trying to compile a particular .cpp file in a large project, and I'm getting the following error from GCC: virtual memory exhausted: Permission denied The file in question is ~25k in size, and less than 600 lines of C++ code. I understand what it means to run out of virtual memory, but I'm not sure what the "Permission denie...

Best C++ IDE for Mac OS X

Hello, I am just looking for a C++ IDE for Apple's OS X. I currently use netbeans for java but cannot find something as robust as this for C++. Thanks! ...

virtual function redefinition hides other overloaded functions of same name from another base class

Ok, I'm using virtual functions, overloaded functions, and multiple inheritance. Of course this doesn't turn out well. The scenario: Class base1 has a virtual function that needs to be specified by its child. Class derived derives from two parents base1 and base2, and should use base2's existing functionality to define base1's virtual ...

Emulate mouse select messages between windows

Hi, I've got two windows in the same process. Window 1 contains some text. Window 2 contains a bitmap of the contents of window 1. Whenever I click (WM_LBUTTONDOWN ) or move (WM_MOUSEMOVE) the cursor in window 2, i pass the message into window 1 by posting the message to window 1's message queue. I now want to emulate more complex...

how to work with const in a map?

I'm having problems with this call: m_baseMap.find(baseName)->second->AddVehicale(vehicaleToAdd); There's a red line under m_baseMap, the error is : "the object has type qualifiers that are not compatible with the member function". The base map is defined as the following: map <string, const Base*> m_baseMap; How can I fix it? ...

QT mouse event handling problem

Greetings all, As seen in the picture I have an extended QWidget object (which draws the cell images and some countour data) inside a QScrollBar. User can zoom in/out the Image (QWidget size is changed according to the zoomed size of the QImage ) using mouse wheel. I process the events (mouseMoveEvent(),wheelEvent()..etc) by impleme...

2 overloads have similar conversions

A similar question to this http://stackoverflow.com/questions/1950840/c-function-overloading-similar-conversions has been asked and i understand the general premise of the problem. Looking for a solution. I have 2 overloaded functions: virtual IDataStoreNode* OpenNode(const char *Name, bool bCreateIfNotExist,int debug=0) { return 0; ...

const and STL containers

The following std::vector code is giving errors int main() { std::vector<const double> VectDouble; VectDouble.push_back(2.34); VectDouble.push_back(2.33); VectDouble.push_back(2.32); for(std::vector<const double> VectDouble::iterator i=VectDouble.begin();i!=VectDouble.end();++i) std::cout<<*i; } ...

Why doesn't c++ have a mouse over message

really why it doesn't. it can help alot of programmers. ...

What is the C equivalent to the C++ cin statement?

What is the C equivalent to the C++ cin statement? Also may I see the syntax on it? ...

Explicit Instantiation

This was motivated by this article (page 5) template<class T> T const &f(T const &a, T const &b){ return (a > b ? a : b); } template int const &f<int>(int const &, int const &); int main(){ int x = 0, y = 0; short s = 0; f(x, y); // OK f(x, s); // Is this call well-formed? } Is the call 'f(x, s)' well-fo...

Using a C extern function inside a C++ file: Linking issues with Makefile

Hello, I have an issue. I have defined in C file, read-line.c, a function print, like this: void history_print(void) { /* some stuff */ } In a C++ file, command.cc, I have the following: extern "C" void history_print(void); and then I simply call history_print(). #Use GNU compiler cc = gcc -g CC = g++ -g all: shell tty-r...

Getting random output from Crypto++

Can't figure out why I am getting seemingly random output from the Crypto++ RC2 decoder. The input is always the same, but the output is always different. const char * cipher ("o4hk9p+a3+XlPg3qzrsq5PGhhYsn+7oP9R4j9Yh7hp08iMnNwZQnAUrZj6DWr37A4T+lEBDMo8wFlxliuZvrZ9tOXeaTR8/lUO6fXm6NQpa5P5aQmQLAsmu+eI4gaREvZWdS0LmFxn8+zkbgN/zN23x/sYqIz...

Returning a reference array from a const member function

How do I return an array reference from a const member function? class State{ Chips (&arr() const)[6][7] { return arr_; } Chips val() const { return val_; } } Invalid initialization of reference of type 'Chips (&)[6][7]' from expression of type 'const Chips [6][7]' Thank you. ...

Is it bad practice for a child object to have a pointer to its parent?

In a C++ application, let's say I have a window class, which has several instances of a control class. If my window wanted to notify a control that it had been clicked, I might use: control[n]->onClick(); Now let's say that the control needs to know the size of it's parent window, or some other information. For this I was considering ...

Windows C++ unit testing: testing dll-exported class

Hi everyone, I have a new native C++ class that I want to test. It is exported from a dll (project consists of 1 exe and a lot of dll) What's better: to test it through static linking or through dynamic linking? What do you usually do in your projects? The problem is that in the project that I am working on it will take a lot of time ...

Problem with declaring Metatype in Qt

Hello folks, I am trying to declare my Class as Metatype for Qt but figuring out some problems. It seems that after the MetaType declaration he wants to get access to a copy constructor or something like this which is explicitly not allowed for QObjects as I thought. This is my header: #include <QtCore/QObject> #include <QtCore/QMetaT...

Is it meaningful to optimize i++ as ++i to avoid the temporary variable?

Someone told me that I can write for (iterator it = somecontainer.begin(); it != somecontainer.end(); ++it) instead of for (iterator it = somecontainer.begin(); it != somecontainer.end(); it++) ...since the latter one has the cost of an extra unused temporary variable. Is this optimization useful for modern compiler? Do I need to...

Makefile for Unit Tests in C++

I'm struggling to write Makefiles that properly build my unit tests. As an example, suppose the file structure looks like this src/foo.cpp src/foo.hpp src/main.cpp tests/test_foo.cpp tests/test_all.cpp So, to build the executable test_all, I'd need to build test_foo.o which in turn depends on test_foo.cpp but also on src/foo.o. What...

problem in connecting qradiobutton and qtab widget

Hello Question i have more than 5 radio buttons in my software and i want that when i click a radio button then the text related to that button appears into the Qtab widget. but i tried a lot but when i click a radio button the text related to that radio button doesn't appear into the Qtabwidget. my header file v_lab.h is here...