c++

STL vector reserve() and copy()

Greetings, I am trying to perform a copy from one vector (vec1) to another vector (vec2) using the following 2 abbreviated lines of code (full test app follows): vec2.reserve( vec1.size() ); copy(vec1.begin(), vec1.end(), vec2.begin()); While the call to vec2 sets the capacity of vector vec2, the copying of data to vec2 seems to not ...

Develop In C++ For Windows CE In Linux

Hello, How i can develop and compile command line C++ programs in my Linux Ubuntu, for my Jornada 720 that have a Windows CE 3.1(HPC 2000), something like a compiler like that for Palm or something like gcc, and a tutorial of development and compiling will be very nice, remember that i want to build command line programs to Windows CE, ...

C++ WxWidgets: Redirecting Stdout to a wxTextCtrl across mulitple threads

My application is a multi threaded app (using wxThreads). At the moment, the main thread along with it's child worker threads are outputting various messages to Stdout (using cout). I have a new frame/window with a wxTextCtrl, and would like to redirect all the StdOut messages in to it. GuiLogFrame *logframe; logframe = new...

Using "this" in front of member variables in C++

Possible Duplicates: Is excessive use of this in C++ a code smell Given that most organizations have a coding standard for member variables like "m_memberVar" or "memberVar_", are there good reasons to use "this->memberVal" format instead? Is there any reason not to? ...

How do I overload the << operator?

I intend to call a function whenever m_logger<<"hello"<<"world" is called. m_logger is of type ofstream. So i decide to overload << with following signature friend ofstream& operator<<(ofstream &stream,char *str); However the vc compiler gives following error: error C2666: 'operator <<' : 6 overloads have similar conversions Is...

Possible to break a loop when outside of it?

After trying to make a while(bool) loop and it failing because I couldn't see the contents of the vectors because there was nothing in them, I made a while(true) loop with the intention of breaking out if the user inputs a 0. Here are the important portions of the code. Edit: Working code, but what does|= mean? #include "std_lib_facili...

C++ WxWidgets: Single log window for messages from Multiple Threads

What's the best/proper method to collect log messages from multiple threads and have them all be displayed using a window? (while the threads are running). I am currently trying to redirect stdout (cout) in to a wxTextCtrl but failing miserably when attempting to do so over multiple threads. Any help would be appreciated. ...

Get an audio session's volume level

Does anyone know how to get the current volume level of an audio session* in Vista or 7? I've got the IAudioSessionControl2 and IAudioSessionManager2 instances you need to listen for volume changes, but actually getting the current volume is proving elusive. *by audio session I mean (roughly) the per-application audio control, not the ...

C++ Reverse Array

In C++, I need to read in a string from user input and place it into a char array [done] Then, I need to pass that array to a function [done] That function is supposed to reverse the order of characters [problem!] Then after, back in the main(), it displays that original array with the newly reversed characters. I'm having trouble cr...

How do I get IP address from socket In Windows

I have the DWORD socket in windows. I need to know if it is a connection that goes out to the internet or if it is a local connection, to some form of localhost. Is there a good way to get the address that the socket is connected to in windows from just the socket? Or is there a better way to tell if the connection is local or not? ...

Platform independent math library

Is there a publically available library that will produce the exact same results for sin, cos, floor, ceil, exp and log on 32 bit and 64 bit linux, solaris and possibly other platforms? I am considering the following alternatives: a) cephes compiled with gcc -mfpmath=sse and the same optimization levels on each platform ... but its n...

Sorting with two vectors

I'm wondering if it's possible if you have, for example, a vector<string> and a vector<double> with corresponding pairs, to sort the vector<string> alphabetically while keeping the pairs matched up. I know this can be done by creating a class that holds both values and just sorting that, but I'd rather keep two separate vectors. Any id...

Question about inheritance

class B{ private: void DoSomething(); } class W{ private: class D: public B{ } D d; } Can I call private member function in base class of D in the scope of class W? ...

variable allocation in a nested loop question

because obj, the playingCard object is created inside a nested for loop does that mean after the second for loop completes, obj gets deallocated from the stack each time? and a small side question, does a compiler use the stack (similar to recursion) to keep track of loops and nested loops? for(int c = 0;c<nElems;c++) { for(int...

Download a URL in C++

I want to be able to download a URL in C++. Something as simple as: std::string s; s=download("http://www.example.com/myfile.html"); Ideally, this would include URLs like: ftp://example.com/myfile.dat file:///usr/home/myfile.dat https://example.com/myfile.html I was using asio in Boost, but it didn't really seem to have the cod...

Removing a compiled method from the .h file and its consequences

I have a binary that has always existed. It has a class C that it has always existed as well. We have to introduce a new method M to the class C but we only want some users to be aware of the existence of such method M. By removing from the .h file such method, which problem we can introduce? Will such approach be backward compatible? ...

Checking for existance of Windows API Functions

I am new to Windows programming and I'm trying to discover the best way to check for the existence of Windows Shell API functions. I want to use some of the new taskbar features in Windows7. http://msdn.microsoft.com/en-us/library/dd378460%28VS.85%29.aspx#custom_jump_lists But I still want my program to be usable by previous versions o...

Fixed Length Float in C/C++?

Hi all, I was wondering whether it is possible to limit the number of characters we enter in a float. I couldn't seem to find any method. I have to read in data from an external interface which sends float data of the form xx.xx. As of now I am using conversion to char and vice-versa, which is a messy work-around. Can someone suggest in...

How can I change QT GUI widgets on a QMainWindow from a QThread which is a member?

I have my main form made QT Designer and inheriting from QMainWindow and the UI. I need to have other threads running, and I need those threads to change things on the main form, eg progress bars, LCDs. How do I give the other thread access to the widgets on the main form? Thanks for any help. ...

Windows Service: to code a software security feature

i want to implement a windows service that functions as a simple license security feature for a software X. The service is meant to run independently from software X. The rough idea: The service is like a timebomb for a software Z installed on the machine... Whenever the user runs software X, the service pops up a window every 30 minu...