c++

Which STL container is best for std::sort? (Does it even matter?)

The title speaks for itself .... Does choice of container affects the speed of the default std::sort algorithm somehow or not? For example, if I use list, does the sorting algorithm just switch the node pointers or does it switch the whole data in the nodes? ...

Pure Virtual Function Call

I obviously do not 'grok' C++. On this programming assignment, I have hit a dead end. A runtime error occurs at this line of code: else if (grid[i][j]->getType() == WILDEBEEST) { ... with the message "Runtime Error - pure virtual function call." From my understanding, this error occurs if the function reference attempts to call the...

Speeding up virtual function calls in gcc

Profiling my C++ code with gprof, I discovered that a significant portion of my time is spent calling one virtual method over and over. The method itself is short and could probably be inlined if it wasn't virtual. What are some ways I could speed this up short of rewriting it all to not be virtual? ...

How does delete[] know it's an array? (C++)

Alright, I think we all agree that what happens with the following code is undefined, depending on what is passed void deleteForMe(int* pointer) { delete[] pointer; } The pointer could be all sorts of different things, and so performing an unconditional delete[] on it is undefined. However, let's assume that we are indeed passing...

What is the best way to port from Objective-C to C++?

I have no Objective-C experience whatsoever but have a strong C++ background. Is there an automated tool/script or, worst case, some manual method using some excellent reference to port code written in Objective-C to C++? What are the difficulties involved? Edit: I'm told the code uses Objective-C fairly trivially. It's an iPhone app th...

Help me convert my Lisp code to a C-based syntax

If you know LISP, could you please change this into C-based sytnax for me (ie. C/C++/C#/Java ..etc)? (let ((g (* 2 (or (gethash word good) 0))) (b (or (gethash word bad) 0))) (unless (< (+ g b) 5) (max .01 (min .99 (float (/ (min 1 (/ b nbad)) (+ (min 1 (/ g ngood)) ...

what is the exact difference between Closed and Stopped State in PPP State machine

I wanted to know what is the exact difference between Closed and Stopped State in PPP State machine. It would be great full if someone explain in detail. I am designing ppp stack using C++. Thanks a lot in advance. ...

Looking for cross platform Packet Capture Library

Hello beside wincap , is there any recommended cross platform Packet Capture Library to use with c/c++ ? Thanks ...

Linker Error while building application using Boost Asio in Visual Studio C++ 2008 Express

I just started writing a small application in C++ using Visual Studio C++ 2008 Express. I installed the Boost Library using the windows installer. While compiling the program i get the following error : Compiling... stdafx.cpp Compiling... websave.cpp GoogleAuthenticate.cpp Generating Code... Compiling manifest to resources... Microsof...

Please, describe you experience of using Microsoft C++/CLI

C++/CLI is very powerful language. It's the only CLR language where you can seamlessly combine managed and unmanaged code. How many software developers (on this site) are using this language? In what kind of projects do you use it? Is it an adapting of legacy code or creation of an original software? Can you compare old Managed C++ wit...

C++ blowfish works with fewer letters,but C# blowfish doesn't

Hello, a C++ blowfish supports encrypting a block with less than < 8 letters,while .NET doesn't.Why? -->C# NET Blowfish<-- -->C++ Blowfish<-- In both C++ and C# applications,I encrypt the following array byte response[6] = { 0x00, 0x80, 0x01, 0x61, 0x05, 0x06 }; In both C++ and C# applications,I call the Encrypt function w...

What`s wrong with qt 4.5.0 integration with Visual Studio 2008?

I downloaded and installed qt evaluation for vs2008 and expect it to be integrated with VS, but it is not. It is trial 30 days commercial license. What`s wrong with it or may be I got it wrong? ...

Why doesn't delete set the pointer to NULL?

I always wondered why automatic setting of the pointer to NULL after delete is not part of the standard. If this gets taken care then many of the crashes due to invalid pointer would not occur. But having said that I could think of couple of reasons why standard would have restricted this: 1. Performance: An additional instruction co...

How to do Latin1-UTF8 encoding change in C++ (maybe with Boost)?

My source base is mostly using UTF8, but some older library has Windows Latin1 encoded strings hardcoded within it. I was hoping Boost would have a clear conversion feature, but I did not find such. Do I really need to hand-code such a commonplace solution? Looking for a portable solution, running on Linux. (This Q is similar, but no...

I am trying to return a Character Array but i'm only getting the first letter!

I'm working on a small little thing here for school. After hours of researching, and a ton of errors and logic reworking I've almost completed my little program here. I'm trying to take user input, store it into the string, get a character array from the string ( dont ask why, I just have to put this into a character array ), then get t...

read text file into class object type array ( C++ )

So i have a class object type, myClass classType as a global. whats not happeing is that would prefer to have // MyClass.h { private: char FirstName; char LastName; char MiddleName; int ID; int Age; }; // Globals const int myIndex = 256; myClass classType[ myIndex ]; int main() { // assume preprocessors are ...

compile error: cpumask.h: "and" may not appear in macro parameter list

I'm trying to move a project from an old linux platform to a kubunutu 9.04. Now I get this error when compiling with gcc 4.3.3: /usr/src/linux-headers-2.6.28-11-generic/include/linux/cpumask.h:600:37: error: "and" may not appear in macro parameter list If I understand the message right, it is not allowed to use "and" as a macro parame...

Create class diagram from c++ source?

Is there any free tools available for generating class diagram from c++ source files and if possible for mfc source files too. ...

Class containing auto_ptr stored in vector

In an answer to http://stackoverflow.com/questions/700588/is-it-safe-to-store-objects-of-a-class-which-has-an-stdautoptr-as-its-member-v I stated that a class that contained an auto_ptr could be stored in a vector provided the class had a user-defined copy constructor. There were several comment suggesting that this was not the case, s...

What is the best way I should go about creating a program to store information into a file, edit the information in that file, and add new information.

I'm about to start on a little project i'm trying to do where I create a C++ program to store inventory data into a file ( I guess a .txt will do ) • Item Description • Quantity on Hand • Wholesale Cost • Retail Cost • Date Added to Inventory I need to be able to: • Add new records to the file • Display any record in the f...