c++

Overloading the ostream << operator for a static class?

I have a (simplified) static global class and << operator overload as follows: class Global { private: static int counter; Global(){}; public: friend ostream& operator<<(ostream &out, Global &global); } ostream& operator<< (ostream &out, Global &global) { //... do output return out; } I want to be able to...

Nested class forward declaration for template inheritance

What's the proper way to inherit from a template class with the template argument being a nested class within the inheriting class? class SomeClass : public TemplateClass<NestedClass> { class NestedClass {}; }; ...

How can I create memory dumps and analyze memory leaks?

I need to get the following to analyze a memory leak issue. How to do that? Orphan Block Addresses Orphan Call Stack Are there any good resources/tools to know about/fix memory leaks. Thanks ...

Overloading Insertion Operator in C++

I have a class in which I'm trying to overload the << operator. For some reason, it is not being overloaded. Here is my .h file: friend std::ostream& operator<<(std::ostream&, const course &); //course is my class object name in my .cpp, I have this as my implementation: std::ostream& operator<<(std::ostream &out, const course & rhs...

Can't include dynamic library header file in more than one file?

I have successfully added a dynamic library to a program, but when I try to include the header file in a second file of the project I get errors about class redeclaration. I will add more info if this isn't enough ...

QtScript -- script-side callback through C++-side implementation

The solution may be simple. Then again it may not be possible. I have the base callback class: class CFCallback { int command_; int transfer_rate_; public: CFCallback(int command, int transfer_rate = 0) { command_ = command; transfer_rate_ = transfer_rate; } virtual ~CFCallback() {} virtual void operator...

C\C++ open source Mp3 to PCM convertor

C\C++ open source Mp3 to PCM convertor? What do I need Open Source Libs/wrappers for encoding/decoding. Tutorials and blog articles on How to do it, about etc. ...

C/C++ PCM open source audio analizer

C/C++ PCM opensource audio analizer? What do I need Open Source Libs/wrappers for encoding/decoding. Tutorials and blog articles on How to do it, about etc. ...

Isn't there a point where encapsulation gets ridiculous?

For my software development programming class we were supposed to make a "Feed Manager" type program for RSS feeds. Here is how I handled the implementation of FeedItems. Nice and simple: struct FeedItem { string title; string description; string url; } I got marked down for that, the "correct" example answer is as follo...

Boost.Asio documentation is non-existent. What do these errors mean?

I'm struggling with two errors with Boost.Asio. The first occurs when I try to receive data on a socket: char reply[1024]; boost::system::error_code error; size_t reply_length = s.receive(boost::asio::buffer(reply, 1024), 0, error); if (error) cout << error.message() << endl; //outputs "End of file" The second occurs when I try to cr...

What does "#include <sndfile.h>" mean?

What does "#include <sndfile.h>" mean? (Sorry I'm c\c++ nub) By the way I know ActionScript and HTML. ...

Boost::Regex DOTALL flag

Is there a DOTALL matching flag for boost::regex? The documentation shows: static const match_flag_type match_not_dot_newline; static const match_flag_type match_not_dot_null; but no mention of regular DOTALL. I'm trying to match a python regular expression written as re.compile(r'<a(.*?)</a>', re.DOTALL) ...

Is boost::make_shared obsolete now?

Is boost::make_shared obsolete now? Haven't found its definition in 1.35. ...

suppress C++ compiler warning from a specific line

I have the following warning: "controlling expression is constant" because of assert statement like this: assert(... && "error message"); how can I suppress warning from this particular line? The compiler I use is NVIDIA cuda compiler. I think it is llvm based. okay, it may not be llvm, as the pragma's do not have any affect. The B...

C++ Win32 API Controls messages

Hi, im starting with Win32 api, im adding a button control to my main window with the flowing code: HWND boton = CreateWindow( "BUTTON", // "Caption", // WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles. 250, // x position. 10, // y position. 100, // Button width...

"g++" and "c++" compiler

Hi, I just found on my Ubuntu, there are two different C++ compiler: /usr/bin/g++ and /usr/bin/c++. I am not familiar with the latter, but man c++ just jumps to the manpage of gcc. I wonder what is their difference as C++ compilers? Thanks and regards! ...

C++ Threadsafe Singleton (NOT FOR INIT)

So I want to access a singleton class from multiple threads. Conceptually I'd think that calling non-const methods on this singleton instance would be not thread-safe. I've been looking online and no one seems to address this possible issue. Is there an actual problem with this, is the only issue with Singleton's thread-safety, the initi...

Gecko Javascript to c++

Hey, Im using the xulrunner example application and im trying to work out how to call into c++ code from javascript. I have googled and the best i came up with was to use nsIDOMEventListener interface but have no idea how. Any ideas? ...

A C++ derivative that is backwards-compatible with older C/C++ code?

Does such a language exist? There are a few qualms in C++ that could be fixed with a derivative that is backwards-compatible. ...

Getting return value from a boost::threaded member function?

I have a worker class like the one below: class Worker{ public: int Do(){ int ret = 100; // do stuff return ret; } } It's intended to be executed with boost::thread and boost::bind, like: Worker worker; boost::function<int()> th_func = boost::bind(&Worker::Do, &worker); boost::thread th(th_func); th.join(); My quest...