c++

C++: Hide base static member

In C++, is it possible to have a child class "hide" a base class' static fields and methods? (i.e. A has a field named ABC of type int, B:A and B has a field named ABC of type int) ...

Handling gui with different threads

I'm new in qt and c++, and I have a problem with threads. For example, if I have a gui with two QPushButton and one QTextEdit, is it possible to set values to the QTextEdit from a thread (different from the gui main thread) without freezing the gui? // These are the values that I want to set from the thread for(i=0;i<100;i++){ ...

What are efficient ways to debug an optimized C/C++ program?

Many times I work with optimized code (sometimes even involving vectorized loops), which contain bugs and such. How would one debug such code? I'm looking for any kind of tools or techniques. I use the following (possibly outdated) tools, so I'm looking to upgrade. I use the following: Since with ddd, you cannot see the code, I use gd...

C++ Stack by Array Implementation.

Hey all! Thought I'd post anotherhomework question if thats alright :x What I want to happen is for the pushFront(int) function to do this: bool stack::pushFront( const int n ) { items[++top] = n; // where top is the top of the stack return true; // only return true when the push is successful } items is a struct type of the object...

C++: Convert Macro based Property System to use templates

I've already implemented, using macros, a C++ property system that satisfied the following requirements: Property can be referenced using a integeral key Property can be accessed via a generic Set/Get Properties (and property keys) must be inheritable Properties can be registered with getters/setters and is implemented as follows E...

dialogbox in a MFC program

i have written the following application using MFC in visual c++ that includes two resources (a menu and a dialogbox) (created using the resource editor)...the program works absolutely fine except that it displays only one resource ie. it displays only the menu but it does not display the dialogbox... what to do?? this is the code... #i...

How do I use a pointer to char from SWIG, in Perl?

Hi, I used SWIG to generate a Perl module for a C++ program. I have one function in the C++ code which returns a "char pointer". Now I dont know how to print or get the returned char pointer in Perl. Sample C code: char* result() { return "i want to get this in perl"; } I want to invoke this function "result" in Perl and pr...

Persistant references in STL Containers

When using C++ STL containers, under what conditions must reference values be accessed? For example are any references invalidated after the next function call to the container? { std::vector<int> vector; vector.push_back (1); vector.push_back (2); vector.push_back (3); vector[0] = 10; //modifies 0'th element int& ref = vector[0...

Create registry entry to associate file extension with application in C++

I would like to know the cleanest way of registering a file extension with my C++ application so that when a data file associated with my program is double clicked, the application is opened and the filename is passed as a parameter to the application. Currently, I do this through my wix installer, but there are some instances where th...

C++ with Python embedding: crash if Python not installed

I'm developing on Windows, and I've searched everywhere without finding anyone talking about this kind of thing. I made a C++ app on my desktop that embedded Python 3.1 using MSVC. I linked python31.lib and included python31.dll in the app's run folder alongside the executable. It works great. My extension and embedding code definitely ...

How to effectively delete C++ objects stored in multiple containers? auto_ptr?

I have an application which creates objects of a certain kind (let's say, of "Foo" class) during execution, to track some statistics, and insert them into one or both of two STL maps, say: map<Foo*, int> map1; map<Foo*, int> map2; I was wondering what is the best way to delete the Foo objects. At the moment my solution is to iterate o...

Generating HTML (i.e. br and p tags) from plaintext in C++

I've got a bunch of text like this: foo bar baz What's likely to be the most efficient way in C++ of transforming that to this: <p>foo<br />bar</p> <p>baz</p> for large(ish) quantities of text (up to 8000 characters). I'm happy to use boost's regex_replace, but I was wondering if string searching for \n\n might be more efficient?...

VC6 and template error

Hi, I am overloading operator << to implement a stream like interface for a class: template<typename T> CAudit& operator << ( const T& data ) { audittext << data; return *this; } CAudit& operator << ( LPCSTR data ) { audittext << data; return *this; } The template version fails to compile with "fatal error C1001: INT...

Exception vs. error-code vs. assert

I'm working on a library that generates reports of devices. The generate_report (const std::string& no) member function can fail due to various reasons: invalid report no. invalid state (the report_generator is a FSM) no device is active error during report generation Which error-handling mechanism is best for these errors? just re...

Delay Loading DLLs

Hi I am in desperate need of help, I need to manage an application dependency in Visual Studio. The application links to a DLL only on a specific version of windows, lets say Windows 7. and on other environments, the DLL should not be loaded. How will I be able to achieve that using DLL Delay Loading as this topic is completely new to m...

Is there a working C++ refactoring tool?

Does anybody know a fully featured refactoring tool for C++ that works reliably with large code bases (some 100.000 lines)? I tried whatever i can find again and again over the last years: SlickEdit, Eclipse CDT. They all were not at all usable. SUMMARY: I took time and evaluated "Visual Assist X" as well as "Refactor for C++". Both h...

std::vector and c-style arrays

I am experimenting with OpenCL to increase the speed of our software. We work with maps a lot and, to simplify, represent a map as a std::vector< std::vector >. The OpenCL API takes raw c-style pointers as arguments, for example int* in the case above. My questions: Are there implementation guarantees in the stl that vector is, intern...

How to work around Visual Studio Compiler crashes

We have a large Visual Studio 2005 C++/Mfc solution, 1 project with around 1300 source files (so about 650 .h and 650 .cpp files). We also use Boost and a few other libraries (COM: MSXML, Office). Recently, I've added a few instances of boost::multi_index to speed up things a bit. This all compiles most of the time. But now, when I'm d...

How to implement generator in C++?

I want to know how to implement a generator , like python , in C++? In python, it can use keyword "yield" to do so. But how to do it in C++? ...

Local variable scope question

Why is the following code prints "xxY"? Shouldn't local variables live in the scope of whole function? Can I use such behavior or this will be changed in future C++ standard? I thought that according to C++ Standard 3.3.2 "A name declared in a block is local to that block. Its potential scope begins at its point of declaration and ends ...