c++

Modular programming in C++

Possible Duplicate: C++ program design I want to know how modular programs are written in C++ i.e. how they are analysed, designed etc. Also names of reference books will be helpful. ...

const correctness

I was going through: C++ FAQs about inheritance and decided to implement it (just to learn it) #include "Shape.h" void Shape::print() const { float a = this->area(); // area() is pure virtual ... } now, everything (well, almost) works as described in item: faq:23.1 except that print() is const and so it can't access th...

Can C++ memory leaks negatively affect CPU usage?

Hi all, I have a C++ program that has a pretty terrible memory leak, about 4MB / second. I know where it's coming from and can fix it, but that's not my main problem. My program is taking up a very large amount of CPU usage and it isn't running as fast as I want it to. I have two different threads in the program. One by itself takes ~50...

Working on a cross platform library...

What are the best practices on writing a cross platform library in C++? My development environment is Eclipse CDT on Linux, but my library should have the possibility to compile natively on Windows either (from Visual C++ for example). Thanks. ...

VS2008 Link Error Using SafeInt3.hpp in 64bit mode.

I have the below code that links and runs fine in 32bit mode - #include "safeint3.hpp" typedef SafeInt<SIZE_T> SAFE_SIZE_T; SAFE_SIZE_T sizeOfCache; SAFE_SIZE_T _allocateAmt; Where safeint3.hpp is current version that can be found on Codeplex SafeInt. For those who are unaware of it, safeint is a template class that makes working wit...

How to check value of defined symbols (Eclipse->Paths & Symbols) in a makefile?

We have a project that used to be an Eclipse-managed CDT project. However, I am trying to change it to a standard makefile project. One of them has a couple of symbols defined in Project Properties->C/C++ General->Paths & Symbols->Symbols. The makefiles generated by Eclipse used to automatically get the value when it was managed. Th...

How to share an array in Python with a C++ Program?

I two programs running, one in Python and one in C++, and I need to share a two-dimensional array (just of decimal numbers) between them. I am currently looking into serialization, but pickle is python-specific, unfortunately. What is the best way to do this? Thanks Edit: It is likely that the array will only have 50 elements or so, bu...

Qt - Password field

Is there any Qt-built-in method to warn user (with pop-up window) that CapsLock is switched on while password field is active? I am using for passford field QLineEdit (is it good?) with setEchoMode(QLineEdit::Password). ...

Qt - QDialog's "?" button

I create an instance of QDialog and on the left of 'x' (close) button i have also '?' button. How I can disable that '?' ? ...

Smplest way to provide template specialization for derived classes

I have following scenario: class my_base { ... } class my_derived : public my_base { ... }; template<typename X> struct my_traits. I want to specialize my_traits all classes derived from my_base including: i.e. template<typname Y> // Y is derived form my_base. stryct my_traits { ... }; I have no problems to add any tags, members...

C++ memcpy problem :(

Hey all :) I have a problem my src pointer of memcpy is pointing wrong. unsigned char* lpBuffer is a buffer that contains my bytes, i checked with olly. The code: IMAGE_DOS_HEADER iDOSh; memcpy(&iDOSh,lpBuffer,sizeof(iDOSh)); The problem is that lpBuffer points wrong, output from debugger is dest = 002859E8 RIGHT src = 000001D8 ...

deleting an object

Hi, First, when you want to free the memory assigned to an object in C++, which one is preferred? Explicitly calling destructor or using delete? Object* object = new Object(...); ... delete object; OR object->~Object(); Second, does the delete operator call the destructor implicitly? Thanks, ...

Reading MP3 files

I want to read MP3 files in C++ and I prefer to write my own code for this. Basically to learn how the filetype works. I want to read all the bits of hex data of a MP3 file and have my speakers play it. :) I have no idea where to start since I don't yet know how data is actually stored into a MP3 file. Thanks for your help ...

How to call a c++ function using c && redirect application output to textEdit in Qt

I'm trying to do a couple of things at once. I'm trying to do one major thing: redirect the application output that is displayed in the Qt Creator console to a textEdit that I have on my GUI. However, the class that I need to do this in is written in C and all of its related headers are in C as well. Is there a way that I can redirec...

extend php with java/c++?

i only know php and i wonder if you can extend a php web application with c++ or java when needed? i dont want to convert my code with quercus, cause that is very error prone. is there another way to extend it? cause from what i have read python can extend it with c++ without converting the python code and use java with jython? ...

C++: How to use types that have not been defined?

C++ requires all types to be defined before they can be used, which makes it important to include header files in the right order. Fine. But what about my situation: Bunny.h: class Bunny { ... private: Reference<Bunny> parent; } The compiler complains, because technically Bunny has not been completely defi...

Recursive breadth-first travel function in Java or C++?

Here is a java code for breadth-first travel: void breadthFirstNonRecursive(){ Queue<Node> queue = new java.util.LinkedList<Node>(); queue.offer(root); while(!queue.isEmpty()){ Node node = queue.poll(); visit(node); if (node.left != null) queue.offer(node.left); if (node.right != n...

Best way to access nested data structures?

I would like to know what the best way (performance wise) to access a large data structure is. There are about hundred ways to do it but what is the most accessible for the compiler to optimize? One can access a value by foo[someindex].bar[indexlist[i].subelement[j]].baz[0] or create some pointer aliases like sometype_t* tmpfoo = &f...

Reporting library for Linux / C++ / Gtk?

We have a C++ Gtk application that currently has a "homebrew" reporting component. We're looking to step up to a more fully-featured reporting library, preferably with a WYSIWYG designer, print-preview / GUI viewer, and PDF export capabilities. Any recommendations? ...

Make GNU make use a different compiler

How can I make GNU Make use a different compiler without manually editing the makefile? ...