c++

Which Singleton library in BOOST do you guys choose?

hi, Google results say there are more than 1 singleton template/baseclass in boost, which one do you suggest? Can anyone give me a clue? Thanks ...

Uses of a C++ Arithmetic Promotion Header

I've been playing around with a set of templates for determining the correct promotion type given two primitive types in C++. The idea is that if you define a custom numeric template, you could use these to determine the return type of, say, the operator+ function based on the class passed to the templates. For example: // Custom nume...

MP3 codec for WAV files

Wav files support different encodings, including mp3. Is there a C/C++ library that would produce mp3-encoded wav files from uncompressed wav? If not, what would be the best place to start to implement one? ...

How is the Windows menu in a MFC C++ app populated.

One of the standard menus provided to a Document/View app under MFC is the Windows menu. It provides things like tiling and cascading windows, and appends an enumerated list of currently available views at the end of the menu. Problem is, sometimes it doesn't and I'd like to know why. More specifically, I'd like to know how to refresh...

C++ copy constructor function question

Hi, I wonder if there is something wrong with the copy constructor function below? class A { private: int m; public: A(A a){m=a.m} } Thanks and regards! ...

LIBPATHS not being used in Makefile, can't find shared object

I'm having trouble getting a sample program to link correctly (in this case against the ICU library). When I do 'make', everything builds fine. But when I run it, it says it can't find one of the .so's. I double checked they're all installed in /usr/local/lib. What I discovered was it was looking in /usr/lib. If I symlink from there to t...

C++ Mock/Test boost::asio::io_stream - based Asynch Handler

I've recently returned to C/C++ after years of C#. During those years I've found the value of Mocking and Unit testing. Finding resources for Mocks and Units tests in C# is trivial. WRT Mocking, not so much with C++. I would like some guidance on what others do to mock and test Asynch io_service handlers with boost. For instance, in ...

Symbian c++ - how to put own static lib

Hello guys. I'm using carbide c++. What to put in .mmp file to link some static library in path: camerawrapper\epoc32\release\armv5\lib from root? ...

Code Complete 2ed, composition and delegation.

Hi there. After a couple of weeks reading on this forum I thought it was time for me to do my first post. I'm currently rereading Code Complete. I think it's 15 years since the last time, and I find that I still can't write code ;-) Anyway on page 138 in Code Complete you find this coding horror example. (I have removed some of the ...

Reusing a vector in C++

I have a vector declared as a global variable that I need to be able to reuse. For example, I am reading multiple files of data, parsing the data to create objects that are then stored in a vector. vector<Object> objVector(100); void main() { while(THERE_ARE_MORE_FILES_TO_READ) { // Pseudocode ReadFile(); ParseFileInt...

easy hex/float conversion

I am doing some input/output between a c++ and a python program (only floating point values) python has a nice feature of converting floating point values to hex-numbers and back as you can see in this link: http://docs.python.org/library/stdtypes.html#additional-methods-on-float Is there an easy way in C++ to to something similar? and...

Qt: How to force a hidden widget to calculate its layout?

What I am trying to do is render a qwidget onto a different window (manually using a QPainter) I have a QWidget (w) with a layout and a bunch of child controls. w is hidden. Until w is shown, there is no layout calculations happening, which is expected. When I call w->render(painter, w->mapToGlobal(QPoint(0,0)), I get a bunch of cont...

Alternatives to C++ Reference/Pointer Syntax

What languages other than C and C++ have explicit reference and pointer type qualifiers? People seem to be easily confused by the right-to-left reading order of types, where char*& is "a reference to a pointer to a character", or a "character-pointer reference"; do any languages with explicit references make use of a left-to-right readin...

Please explain syntax rules and scope for "typedef"

What are the rules? OTOH the simple case seems to imply the new type is the last thing on a line. Like here Uchar is the new type. typedef unsigned char Uchar; But a function pointer is completely different. Here the new type is pFunc: typedef int (*pFunc) (int); I can't think of any other examples offhand but I have come across...

Compiling/Debugging LZMA

Hello everyone. I need to compile the C++ implementation of LZMA (7Z). Does anybody know how to do that? where should I download it from? Thanks so much in advance. ...

CIELab Colorspace conversion

Is there a canonical colorspace conversion library? I can't find any pre-existing solutions. Is CIELab conversion is too obscure? ...

how to run QT from command line in windows

hi all, i installed Qt4 and Qt creator. now i need to know how can i run an application with in command line. I installed QT and QT creator. If i need to create a project i need to open the Qt Creator and create new project and write the code there, compile/build with the QT creator. Is that the procedure in QT. So in this case am not a...

Access modifiers in Object-Oriented Programming

I don't understand Access Modifiers in OOP. Why do we make for example in Java instance variables private and then use public getter and setter methods to access them? I mean what's the reasoning/logic behind this? You still get to the instance variable but why use setter and getter methods when you can just make your variables public? ...

Using boost::spirit, how do I require part of a record to be on its own line?

I have a record parser that throws one of several exceptions to indicate which rule failed. Front matter: #include <iostream> #include <sstream> #include <stdexcept> #include <string> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix.hpp> #include <boost/spirit/include/classic_position_iterator.hpp> using ...

tricky interview question for C++

Given the code below, how would you create/implement SR.h so that it produces the correct output WITHOUT any asterisks in your solution? I got bummed by this question. I would like to know some of the different approaches that people use for this problem. #include <cstdio> #include "SR.h" int main() { int j = 5; int a[] = {10,...