c++

How do I set EOF on an istream without reading formatted input?

I'm doing a read in on a file character by character using istream::get(). How do I end this function with something to check if there's nothing left to read in formatted in the file (eg. only whitespace) and set the corresponding flags (EOF, bad, etc)? ...

Why do I get a segmentation fault when calling a virtual method in this code?

I'm still learning C++; I was trying out how polymorphism works and I got a segmentation fault when calling a virtual method. (Note: I didn't mark the destructor as virtual, I was just trying out to see what happens.) Here's the code: #include <iostream> using namespace std; class Base { protected: char *name; public: Base(char ...

Simple email program / library recommendations

Hello all, I am needing to implement email notifications for a C++ project. Basically a user provides all the relevant information for their email account and on certain events this component would fire off an email. Ideally I would like to find a small cross platform open source command line project that I can exec from within my pro...

C++ and STL refresher course

Hi! I know C and C++ quite well. I know in much detail about pointers and well versed with pointer arithmetic and worked on Win32 API and a bit of MFC as well in my university days. In my previous job, I had no chance to look on these matters and worked in some other domain. Now what I want is a crash or refresher course in: C++ STL ...

rules with temporary objects and args by reference

say I have a class: class A { public: A() {} }; and a function: void x(const A & s) {} and I do: x(A()); could someone please explain to me the rules regarding passing temporary objects by reference? In terms of what the compiler allows, where you need const, if an implicit copy happens, etc. From playing around, it seems like...

Opensource C/C++ decompiler

Duplicate of http://stackoverflow.com/questions/193896/whats-a-good-c-decompiler and http://stackoverflow.com/questions/205059/is-there-a-c-decompiler taken together. Does somebody know any opensource C/C++ decompiler? I don't want to use any commercial solution like IDA Pro. ...

Learning to work with audio in C++

My degree was in audio engineering, but I'm fairly new to programming. I'd like to learn how to work with audio in a programming environment, partly so I can learn C++ better through interesting projects. First off, is C++ the right language for this? Is there any reason I shouldn't be using it? I've heard of Soundfile and some other li...

Docking control bars/panes to CMDIFrameWndEx?

In one of our applications I've used some of the MFC classes to allow docking a sidebar window, approximately like so: CDialogBar* bar = new CDialogBar; bar->Create(this, IDD, WS_CHILD | WS_VISIBLE | CBRS_RIGHT | CBRS_TOOLTIPS, IDD)); bar->EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT); DockControlBar(b...

How can I call a .NET form from an MFC application?

We have a several large MFC applications which presently call a COM object to bring up a complex dialog. We would like to integrate the dialog into the applications -- we do not want to continue to use a COM object. I'm investigating the possibility of building the dialog in .NET as a separate project (using Windows forms, not WPF) and...

Template Meta-programming with Char Arrays as Parameters.

I'm playing around with TMP in GCC 4.3.2's half-implementation of C++0x, and I was wondering if there was a way to somehow do the following: template <char x, char... c> struct mystruct { ... }; int main () { mystruct<"asdf">::go(); } It obviously won't let me do it just like that, and I thought I'd get lucky by using user-defin...

Open Source C++ projects for beginners

Hello everyone! I am trying to get into some open source projects that use C++. I have looked at some on sourceforge, tried Google Chrome, OpenOffice.org, but they are too hard of projects. I know some C++, but I just want something that will be easy to add to and fix and can help me polish my C++ skills for the bigger projects. Can anyo...

what is the usefulness of enable_shared_from_this

I ran across enable_shared_from_this while reading the Boost.Asio examples and after reading the documentation I am still lost for how this should correctly be used. Can someone please give me an example and/or and explanation of when using this class makes sense. ...

enqueue() method adds one element to the queue: how to implement in C++?

I'm having a hard time trying to implement this method since array subscripts in C++ start with zero. The method add one element to the queue. You can use f (front) and r (rear) pointers and a sequential list of size n. If you find that additional variables are needed fell free. Thanks. Thats my try but I know its wrong: void QueueAr::...

dynamic_bit set print?

std::string charBuff = "11010"; dbitset = boost::dynamic_bitset<unsigned char> (charBuff); for (boost::dynamic_bitset<>::size_type i = 0; i < dbitset.size(); ++i) { std::cout << dbitset[i]; } It prints from the LSB to MSB. Output: 01011. What should I do to so that bitset is printed correctly. I can reverse the character buffer ...

Does the evil cast get trumped by the evil compiler?

This is not academic code or a hypothetical quesiton. The original problem was converting code from HP11 to HP1123 Itanium. Basically it boils down to a compile error on HP1123 Itanium. It has me really scratching my head when reproducing it on Windows for study. I have stripped all but the most basic aspects... You may have to press...

Is there any open source program that use the inpout.dll ?

Is there any open source program that use the inpout.dll to hook up the parell port and turn LED's on and off ive been looking for almost a whole month and havent found jack. I want to do this without any microcontrollers. ...

How do you use an exponent in c++ with a variable?

So I realize that #include is necessary, and that there is a pow(x,y) where x^y works...but when I attempted to use pow(2,(num-1)), it kicked back an error... errorC2668: 'pow' : ambiguous call to overloaded function the line of code I have for it is as follows perfect = (pow(2,(num-1))) * (pow(2,num)-1); Any recommendations? Thank...

Please help us non-C++ developers understand what RAII is

Another question I thought for sure would have been asked before, but I don't see it in the "Related Questions" list. Could you C++ developers please give us a good description of what RAII is, why it is important, and whether or not it might have any relevance to other languages? I do know a little bit. I believe it stands for "Resour...

Registering implementation of a COM interface

I'm new to COM programming. I've got a COM object (and associated IClassFactory) all ready to go, but I can't quite figure out how to go about registering the resulting DLL for use by other programs. The number of GUIDs I need to sling around is also unclear to me. The COM object I'm trying to register implements the IAudioSessionEven...

Callback Routine Not Getting Triggered

I've created a very simple one-button MFC dialog app that attempts to utilize a callback function. The app complies and runs just fine, but the callback routine never gets triggered. What needs to be modified in order to get the callback to trigger properly? You can download the test.zip file here (the test app is in VS 2003 to ensure...