c++

What's the worst example of undefined behaviour actually possible?

In questions about things not to do in C++ such as dereferencing a dangling pointer or calling delete twice for the same address I often see the statement that it's undefined behaviour and anything can happen - the program can overwrite the system disk or offend my parents. What is the worst real example of undefined behaviour consequen...

Question about the assignment operator in C++

Forgive what might seem to some to be a very simple question, but I have this use case in mind: struct fraction { fraction( size_t num, size_t denom ) : numerator( num ), denominator( denom ) {}; size_t numerator; size_t denominator; }; What I would like to do is use statements like: fraction f(3,5); ... doub...

Important concepts you learn from a Programming Book

Hello, I've been recently learning how to program and had read at least 1 full book to start learning. As the book taught C++, I wrote some small programs and applications to understand the concept, but wondered, what concepts are important? Example is the "friend" in OOP, where source codes that I look at does not use this often, and I...

what happens when you modify an element of an std::set?

Like the question says, If I change an element of an std::set, for example, through an iterator, I know it is not "reinserted" or "resorted", but is there any mention of if it triggers undefined behavior? For example, I would imagine insertions would screw up. Is there any mention of specifically what happens? ...

regarding conversion from reference to string

hi, i am doing RSA encryption i want to convert reference of public key class to string so that i can pass to server //declaration const CRSAPrivateKey &iRSAPrivateKey =iRSAKeyPair->PrivateKey(); const CRSAPublicKey &iRSAPublicKey =iRSAKeyPair->PublicKey() ; i have convert &iRSAPublicKey into TBuf i tried lot but fails to conver...

Matlab vs. Visual C++??

I'm doing a Windows Application the uses lots of charts.. Its practically a dataviewer.. I started doing Matlab, because its easier, but I realized it's too slow.. I wanted to change to another language.. Somebody recommended me Visual C++ or Java.. But Im not sure.. What language should I use?? ...

AES in symbian

Hi, PKCS5padding and CBC cipher mode and init vector(IV) how to achieve in AES in symbian I have used CAESEncryptor , CAESBufferedEncryptor are any other options availabl for the same ...

Splitting a string

I have this code to split a string. For some reason, it just sits there doing nothing. I am not sure what the problem is. By the way, delim = ' ' here. vector<string> split( const string &str, const char &delim ) { typedef string::const_iterator iter; iter beg = str.begin(); vector<string> tokens; while(beg != str....

How can I remove a MS Word add-in button?

I need to programmatically remove an add-in from MS Word. I have deleted the registry entry corresponding to it, and the button is now disabled (nothing happens when you click it) and the add-in no longer appears on the list of COM Add-ins. The button, however, remains in the Add-ins ribbon menu. How can I remove that programmatically? ...

What are good online resources or tutorials to learn C++

What are (good) online resources to learn C++? Preferably resources focused on programmers with experience in other (object-oriented) languages? Possible duplicates: Language Books/Tutorials for popular languages (78 votes) What is the best way to learn C++ if I have a bit of other programming experience? (9 votes) Good b...

Reading dynamically allocated arrays into lists

Currently, I have been reading lists of data from a binary data file programmatically as follows: tplR = (double*) malloc(sampleDim[0]*sizeof(double)); printf("tplR = %d\n", fread(tplR, sizeof(double), sampleDim[0], dfile)); However, as I want to use find_if() function on those lists, I would need to get tplR into a list type in stl....

Is there a smart pointer that is automatically nulled when its target is destroyed in C++

I've found QPointer. Are there any others? ...

How can I hide the DOS Window and bring up a splash screen?

Ive used the Matlab Compiler to create a .exe file.. The program takes 15 sec to start.. So I figured that I needed to get rid of the DOS window and needed a splash screen.. How can I do that?? ...

c++ what happens if you print more characters with sprintf, than the char pointer has allocated?

Hello, I assume this is a common way to use sprintf: char pText[x]; sprintf(pText, "helloworld %d", Count ); but what exactly happens, if the char pointer has less memory allocated, than it will be print to? i.e. what if x is smaller than the length of the second parameter of sprintf? i am asking, since i get some strange behaviour ...

How to know if a process had been started but crashed in Linux

Consider the following situation: - I am using Linux. I have doubt that my application has crashed. I had not enabled core dump. There is no information in the log. How can I be sure that, after the system restart my app was started, but now it is not running, because it has crashed. My app is configured as a service, written in C/C++....

Qt: mouseMoveEvent and interfer with hoverEnterEvent of child object

Hi! I use QGraphicsView to create a sort of circut editor, which has elements in it, which have connectors. It should be possible to connect those connectors with wires. However I have a problem, while I drag from one connector to another, Qt grabs mouse, and other connectors stop receiving hoverEnterEvent. Btw, on hover connectors resiz...

how to implemet POSIX select() based behaviour, within boost::asio

Hello, I've already wasted two days reading documentation of boost::asio And I still don't know how could I implement blocking select() like function for several sockets using only one thread (using boost framework). Asynchronous functions of boost::asio returns immediately, so there would be a need to put some wait function in main thre...

track C++ memory allocations

I am looking for a way to track memory allocations in a C++ program. I am not interested in memory leaks, which seem to be what most tools are trying to find, but rather creating a memory usage profile for the application. Ideal output would be either a big list of function names plus number of maximum allocated bytes over time or better...

Need for predictable random generator

I'm a web-game developer and I got a problem with random numbers. Let's say that a player has 20% chance to get a critical hit with his sword. That means, 1 out of 5 hits should be critical. The problem is I got very bad real life results -- sometimes players get 3 crits in 5 hits, sometimes none in 15 hits. Battles are rather short (3-1...

Possible: Program executing Qt3 and Qt4 code?

Maybe its a very dumb question but I hope you can give me some answers. I have a commercial application which uses Qt3 for its GUI and an embedded Python interpreter (command line) for scripting. I want to write a custom plugin for this application which uses Qt4. The plugin is mainly a subclassed QMainWindow-class that is linked into a...