c++

Do you use curly braces for additional scoping?

I mean other than using it when required for functions, classes, if, while, switch, try-catch. I didn't know that it could be done like this until I saw this SO question. In the above link, Eli mentioned that "They use it to fold up their code in logical sections that don't fall into a function, class, loop, etc. that would usually be ...

Easy to use SNMP client library for c++?

What's an easy to use SNMP client library for c++? ...

Single-threading two processes

I have two C++ processes (A and B), executing under Windows, where one launches the other. I would like to effectively single-thread their execution. For example: Start process A A creates B A suspends B executes some fixed set of operations B suspends and A is resumed A executes some fixed set of operations A suspends and B is resumed...

What is a simple example of floating point/rounding error?

I've heard of "error" when using floating point variables. Now I'm trying to solve this puzzle and I think I'm getting some rounding/floating point error. So I'm finally going to figure out the basics of floating point error. What is a simple example of floating point/rounding error (preferably in C++) ? Edit: For example say I have...

Looking for a better way than virtual inheritance in C++

OK, I have a somewhat complicated system in C++. In a nutshell, I need to add a method to a third party abstract base class. The third party also provides a ton of derived classes that also need the new functionality. I'm using a library that provides a standard Shape interface, as well as some common shapes. class Shape { public: ...

Explain Facade pattern with c++ example?

I have checked with the wikipedia article, and it seems like it is missing the c++ version of a code example. I am not able to fully appreciate the Facade pattern without this, can you please help explain it to me using C++? ...

Are there C++ free and fast (maybe standalone) refactoring tools for Windows?

At the moment I am working in a pretty big project and I have been been asked to refactor some old code. Most of the refactoring is setting apart a big class into smaller components and functions. I've searched and seen some other questions related with the topic but I am not very happy with the proposed options. The problem with these ...

Making Thrift calls from a C++ app in Windows

As the title says, I have a Windows app written in C++ from which I need to make calls to remote Thrift services, and I'm a bit lost on the subject, to be honest. http://wiki.apache.org/thrift/ThriftInstallationWin32 states that "The Thrift C++ runtime library does not currently work on Windows". Does that mean I'm shit out of luck, or i...

C++: ctors for structs?

C++: Since a struct is a class with everything "public", are default -ctors created and called? The reason I ask is to understand the overhead, if any, that C++ may have over C, when structs are used. An opinion I have heard is that classes have some overhead that structs don't, in C++, but I question this. ...

How to read arbitrary number of values using std::copy?

Hi, I'm trying to code opposite action to this: std::ostream outs; // properly initialized of course std::set<int> my_set; // ditto outs << my_set.size(); std::copy( my_set.begin(), my_set.end(), std::ostream_iterator<int>( outs ) ); it should be something like this: std::istream ins; std::set<int>::size_type size; ins >> size; s...

Does anyone know of any C/C++/C# code libraries that do audio synthesizer emulation?

I'm trying to write a software synthesizer that recreates the sounds made by classic synthesizers like the Moog and the DX7. Does anyone know of any code resources for something like this? Thanks. ...

Does the D programming language have a future?

I stumbled several times over D and really asked myself why it isn't more popular. D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. Special attention is given to the needs of quality assurance, document...

How difficult is it to turn a "Java School" programmer into a C or C++ programmer?

My company, a C++ house, is always looking to hire recent grads. However due to the Java Schools phenomenon, we typically end up interviewing strong Java programmers with maybe a minute smattering of C++. Often the C++ classes don't really prepare students for working in C++. Nevertheless, often these are bright kids, eager to learn and ...

What is the use of const overloading in C++?

In C++, a function's signature depends partly on whether or not it's const. This means that a class can have two member functions with identical signatures except that one is const and the other is not. If you have a class like this, then the compiler will decide which function to call based on the object you call it on: if it's a cons...

How can I get the SID of the current Windows account?

Hi there, I am looking for an easy way to get the SID for the current Windows user account. I know I can do it through WMI, but I don't want to go that route. Apologies to everybody that answered in C# for not specifying it's C++. :-) ...

Passing a Class Object to a function (probably by pointer not reference) C++

So let's say I have two different functions. One is a part of the BST class, one is just a helper function that will call on that Class function. I will list them out here. sieve(BST<T>* t, int n); this function is called like this: sieve(t,n) the object is called BST t; I'm going to be using the class remove function within the...

how do you make a heterogeneous boost::map?

I want to have a map that has a homogeneous key type but heterogeneous data types. I want to be able to do something like (pseudo-code): boost::map<std::string, magic_goes_here> m; m.add<int>("a", 2); m.add<std::string>("b", "black sheep"); int i = m.get<int>("a"); int j = m.get<int>("b"); // error! I could have a pointer to a base ...

typedefs for templated classes?

Is it possible to typedef long types that use templates? For example: template <typename myfloat_t> class LongClassName { // ... }; template <typename myfloat_t> typedef std::vector< boost::shared_ptr< LongClassName<myfloat_t> > > LongCollection; LongCollection<float> m_foo; This doesn't work, but is there a way to achieve a si...

STL priority queue with duplicate keys - is it possible??

Hi everybody, I need to store my class A objects in some data structure. In addition, i would like them to be automatically sorted according to a key, which is in my case an embedded object of another class B. Thus I decided to use a STL priority queue. However it is possible that the 2 or more objects B to have the same key value. ...

a struct doesn't belong in an object oriented program ...

Or does it? Should an object-oriented design use a language construct that exposes member data by default, if there is an equally useful construct that properly hides data members? EDIT: One of the responders mentioned that if there's no invariant one can use a struct. That's an interesting observation: a struct is a data structure, i....