In Numerical Recipes they use something I've never seen done before, and couldn't easily find info on:
void fun( std::vector<double> derivatives(const double, const std::vector<double> &) ) { ...; derivatives(...); ...; }
Which I'm guessing is passing the function by reference (is this correct)? Why would this be favorable to using a ...
I'm new to C++ and there's something I just completely don't get. In C#, if I want to use an external library, log4net for example, I just add a reference to the log4net DLL and its members are automatically available to me (and in IntelliSense). How do I do that in non-managed C++?
...
I'm really baffled by this. Have I managed to do something to cause this, or is it an unclosed namespace block in boost, or some bug in VS c++ 2008? I'm definitely sure I've closed all my own namespaces properly, all includes are outside of and above them, and all my header files got include guards.
The boost/function.hpp is only incl...
Is .NET better than Win32 or the othe way around?
Which would be the pros \ cons of both, in what situations one would be better than the other.
Has Microsoft released .Net as a replacement for Win32?
I am not asking about the amount of projects needed to be maintained, but about
new projects being developed, and which would be better f...
What is the best way to unit test a protected method in C++?
In Java, I'd either create the test class in the same package as the class under test or create an anonymous subclass that exposes the method I need in my test class. Because neither of those methods are available to me in C++, what are suggested approaches for testing pr...
I'm trying to implement the Sieve of Eratosthene in C++. However after several attempts at this I always get runtime errors. I'm thinking this has to do with the state of iterators being used get corrupted somewhere. I can't put my finger on it though. Here is my code:
//Sieves all multiples of the current sequence element
bool...
This program has the user input name/age pairs and then outputs them, using a class.
Here is the code.
#include "std_lib_facilities.h"
class Name_pairs
{
public:
bool test();
void read_names();
void read_ages();
void print();
private:
vector<string>names;
vector<double>ages;
string na...
To be able to unit test my C++ code I usually pass the constructor of the class under test one or severel objects that can be either "production code" or fake/mock objects (let's call these injection objects). I have done this either by
Creating an interface that both the "production code" class and the fake/mock class inherits.
Making...
I remember seeing somewhere there "^" operator is used as a pointer operator in Managed C++ code. Hence "^" should be equivalent to "*" operator right??
Assuming my understanding is right, when I started understanding .Net and coded a few example programs, I came across some code like this:
String ^username; //my understanding is you ...
I'm pretty curious about how Windows and Linux does memory management with C++ programs.
The reason of this curiosity is because I've just made 3 very simple programs in C++ portable between Linux and Windows. The code was exactly the same. The hardware too. But the results were incredibly different! Both tests were repeated 10 times an...
What is the best operating system to develop while using C++? I would like the OS that has more tools and software for C++ development. I also want to develop only for the command line, because I find GUI development in C++ to be confusing.
...
I am trying to create some charts of data (eg http://www.amibroker.com/). Is there a C++ library that can do this without a lot of extra work? I'm thinking Qt or wxWindows would have something like it, but it wasn't immediately obvious.
Thanks!
...
Is it possible to compare whole memory regions in a single processor cycle? More precisely is it possible to compare two strings in one processor cycle using some sort of MMX assembler instruction? Or is strcmp-implementation already based on that optimization?
EDIT:
Or is it possible to instruct c++ compiler to remove string duplicates...
i need a data structure to store this info so that: (I have MANY -to- MANY )
1 .given an employee i can find out the projects
2. given the projects i can find the employee
If I use multi map then I will need to maintain 2 maps,
Is there any other data structure that I can use here?
...
I found similar questions but no answer to what I am looking for. So here goes:
For a native Win32 dll, is there a Win32 API to enumerate its export function names?
...
I'm working with the new Windows 7 audio APIs, and I've hit a wall.
Basically, I need to take an IAudioSessionControl2* and get an ISimpleAudioVolume* out of it.
Now, it looks like I can call on IAudioSessionManager->GetSimpleAudioVolume() using the value of IAudioSessionControl2->GetSessionInstanceIdentifier(...). Note that this isn'...
I have an 8 byte message where the differing chunks of the message are mapped to datums of different types (int, bool, etc.), and they vary in bit sizes (an int value is 12 bits in the message, etc.). I want to pass only the bits a datum is concerned with, but I am not sure if there is a better way. My current thoughts is to make a bit...
I am attempting to get Memory leak detection working with the help of these two articles:
http://msdn.microsoft.com/en-us/library/e5ewb1h3%28VS.80%29.aspx
http://support.microsoft.com/kb/q140858/
So in my stdafx.h I now have:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define new new(_NORMAL_BLOCK,__FILE__,__LIN...
C++ does not allow polymorphism for methods based on their return type. However, when overloading an operator this seems possible.
Does anyone know why? I thought operators are handled like methods internally.
Edit: Here's an example:
struct func {
operator string() { return "1";}
operator int() { return 2; }
};
int main( ) {...
I am working on porting a large number of .h and .lib files from native C++ to Managed C++ for eventual use as a referenced .dll in C#.
Please, I know it'd be a lot easier to port the whole thing to .NET, but if I could I would. It's 3rd party and all I have are .lib(no exports) and .h files to work with.
Everything has been going smo...