c++

Can a string literal and a character literal be concatenated?

Why does name misbehave in the following C++ code? string name = "ab"+'c'; How would the equivalent code behave in Java/C#? ...

How to keep together few inseparable text blocks in QTextEdit at the end of current page (throw all on the next page)?

Hello, i have a QTextEdit document which size is different by every print. In the middle of the document i have few blocks of text which are inseparable in the eyes of the user and i have to protect my blocks from splitting on two pages in case the document gets equivalent size. Have you got any solution? ...

does adding new member function into d pointer class break binary compatibility?

Will adding new member function into d pointer class definition break binary compatibility? For example, will the new definition below break binary compatibility compared to the original? (side question, is there a tool that will tell me if a new .so breaks binary compatibility compared to the old .so? If not, how do I check manually?...

How can I return a const ref a to local variable in C++?

I have a function for which I cannot change the function parameters. I need to return a const reference to a std::string created in this function. I tried to use boost shared_ptr, but this doesn't work. Why? How do I make this work? const std::string& getVal(const std::string &key) { boost::shared_ptr<std::string> retVal(new std::...

Mac OSX - Xcode Installation Directory

After Xcode has finished building is there a way to make it copy the executable to specific directory (~/Sites/cgi-bin/). I have the target "Installation Directory" set to the correct folder, with "skip installation" unchecked, but no luck. Is there something i'm missing? Thanks ...

Difference between void main and int main?

Does it matter which way I declare my C++ programs? ...

What's the best programming language to use on a sucky computer?

I have a computer with 128 MB's of RAM (I said it was a piece of crap). It runs Windows XP Professional (slugishly). I don't have to use this computer except at night time when I'm supposed to be in bed, around 1:00 - 4:00 AM. So what is the best programming language / compiler to use? Which is the least RAM dependent. ...

ATL simple object wizard - "Object Xxx already exists" error

I am attempting to create a new COM object in my DLL using the ATL Simple Object Wizard in Visual Studio 2005. I enter the short name for the object, and all of the other fields are derived. However, when I click Next in the wizard, the following error message comes up: Object 'IXxxInterfaceName' already exists I have searched my en...

DECLSPEC_NOVTABLE on pure virtual classes?

This is probably habitual programming redundancy. I have noticed DECLSPEC_NOVTABLE ( __declspec(novtable) ) on a bunch of interfaces defined in headers: struct DECLSPEC_NOVTABLE IStuff : public IObject { virtual method1 () = 0; virtual method2 () = 0; }; The MSDN article on this __declspec extended attribute says that adding ...

How can I link a dynamic library in x-code?

I am currently developing a program in Qt and it uses the library libqextserialport.1.dylib. I build it and run in x-code and it spits back: dyld: Library not loaded: libqextserialport.1.dylib Referenced from: /Users/samuelreh/Desktop/QtOpenCV/build/Debug/QtOpenCV.app/Contents/MacOS/QtOpenCV Reason: image not found The libra...

std::stringstream strange behaviour

Some background information, for a homework assignment I had to write a polish notation calculator using binary trees, for this to work I had to parse command line input so that it would properly build the binary tree and then go over it to give a valid answer to the mathematical expression that was entered. For the parsing I used a std...

Possible bug in _controlfp_s may not restore control word correctly

Hi All, I've stumbled across either a problem with _controlfp_s (Visual Studio 2008), or my understanding of it. I thought the first out parameter returned the control flags before changes of the other parameters are applied. Seems it returns the flags after the change. So, I thought the correct way to use it was like this: // Chop ...

How to Pass Decimal Value as Argument Correctly

I have this: double myDecimal = static_cast<double>(atoi(arg_vec[1])); cout << myDecimal << endl; But why when I pass the argument like this: ./MyCode 0.003 It prints 0 instead of 0.003. ...

Initializing.. which one is more efficient?

I have the following question. Which one of these is better that should be followed and why? string strMyString = "SampleString"; or string strMyString("SampleString"); Thanks in advance. ...

Option Parsers for c/c++?

I've done some looking and there are a whole lot of libraries for command line option parsing, but it is difficult to differentiate between them. Does anyone have any experience with any of them? Is one harder/better/faster/easier/whatever than any of the others? Or should I just grow my own? ...

Adding element to vector

Hi, I was wondering why im losing the information. I have three functions thus far. An option processing function, and two vector functions one for reading a text file and the other for adding a user specifcation to the same vector. Whats happening is that i read the file and save its contents into a vector and then choose the next o...

std::for_each, calling member function with reference parameter

I have a container of pointers which I want to iterate over, calling a member function which has a parameter that is a reference. How do I do this with STL? My current solution is to use boost::bind, and boost::ref for the parameter. // Given: // void Renderable::render(Graphics& g) // // There is a reference, g, in scope with the call...

What would be the correct design for keeping configuration settings in c++?

Say I have ini/json to store configuration setting of my desktop application,Will it be ok to have a static object with all property loaded at startup/when ever it is required or is there any other better alternative? Since this is the very first time I am doing this ,so just wanted to know whether static object is fine or singleton pat...

when connect a c++ sever,flash socket send wrong data.

I write a chat server in c++ and a flash client in flex3. the message exchanged between them is like [message_len+messagebody] where the flash open on my owner windows xp system,it works ok,the message sent and recieved is right. but when I put the flash on a red hat 5 's apache server, try to open it in the web browers, the flash socke...

Why do I get a segmentation fault (core dumped) when I try to allocate a 4D array?

I'm trying to allocate a large 4D matrix but I want to do it dynamically. When I just create the static matrix everything works fine so I know I have enough memory for now. However when I try and implement the same thing dynamically it breaks whenever I enter the third dimension and I need to get to a fourth! Can anyone tell me why th...