I'd like to calculate all the permutations of size Y of a set of size X. That is if I had (1,2,3) and want all permutations of size 2, 3P2, it would be (1,2) (1,3) (2,1) (2,3) (3,1) (3,2).
Both the GSL and C++ STL only provide xPx that I can see. Could someone point me at a C/C++ library which can do this or spell out a fast and memor...
So I am migrating from an "owned" object model to a "managed" object model in a project I am doing. Currently to make a new Thing one does
Thing *thing = new Thing();
and to get rid of it and destroy it the owner does
delete thing
Now there are a lot of "delete thing"s out there and many of them are deleting from a
superclass of...
let's say I have:
set<int, less<int> > m_intset;
that works, but now I change it to typedef, and if I do I end up with two lines of code, right?
typedef set<int, less<int> > SetInt;
SetInt m_intset;
So, what's the use?
Is that the way to change it and use it?
...
I am very new to C++ and still trying to learn syntax and best practices.
I've defined a method with a single parameter:
void foo(const std::string& name)
1) Is this a proper parameter declaration for a function that will be taking in a string defined by the user in, for example, a main method?
2) If this is proper/recommended synt...
Hello every one,
I am failed to find out the free e-books for c & c++ language. ( Specially e-balagurusami if possible )
Actually, I wanted to give this books for trainees for study & revision.
Would you help me to find the e-books for this?
Thanks in advance for helping me.
Sagar.
...
Do you know of a good open source financial library written in C (preferably) or C++?
I already looked at Quantlib, which seems too complicated for me, since I just want some basic computations (total cost of credit, all in-cost credit rate...)
Thank you very much!
...
While there are many guides for Browser Helper Objects, i have a hard time finding resources on how to implement scriptable objects (i.e. besides the main control) for content plugins (i.e. embedded in website).
To avoid misunderstandings: the question is about scriptable objects that a plugin object may return to the scripts in a websit...
I'm attempting to create a CList with a COM smart pointer (one of the wrapper classes generated for _com_ptr_t) as the template parameter:
CList<IDispatchPtr, IDispatchPtr> list;
However I get several compilation errors similar to:
error C2664: 'void __stdcall SerializeElements(class CArchive &,class _com_ptr_t<class _com_IIID<st...
My goal is to create an efficient structure to store the most relevant entries of a matrix that would (in a world without memory limitations) be approximately 10^5 x 10^5 and filled with doubles. The matrix is symmetric, so it actually would contain only (10^10)/2 values.
I need to access entries many, many times in my simulation, so fa...
I'm looking for the best way to modify the Boost Asio HTTP Server 3 example to maintain a list of the currently connected clients.
If I modify server.hpp from the example as:
class server : private boost::noncopyable
{
public:
typedef std::vector< connection_ptr > ConnectionList;
// ...
ConnectionList::const_iterator GetC...
I am using C++ to create a string class. I want the class to only accept the data types char and wchar_t and I want the compiler to catch any invalid data types during compile time using #error. I do not like using assert( ). How can I do this?
...
I'm writing a tic tac toe program that plays throuh the terminal/console
After Player 1 or 2 wins, I give the choice for the user to play again, 1 = play again, 2 to quit.
However, entering 2 to quit doesnt work
//tie check, replay, use pointer notation
#include <iostream>
using namespace std;
void initialize(char [][3]);
void player1(...
I heard C, C++, Java uses two complements for binary representation. Why not use 1 complement? Is there any advantage to use 2 complement over 1 complement?
...
I would like to read a text file and input its contents into an array. Then I would like to show the contents of the array in the command line.
My idea is to open the file using:
inFile.open("pigData.txt")
And then to get the contents of the file using:
inFile >> myarray [size]
And then show the contents using a for loop.
My prob...
I do embedded software, but this isn't really an embedded question, I guess. I don't (can't for technical reasons) use a database like MySQL, just C or C++ structs.
Is there a generic philosophy of how to handle changes in the layout of these structs from version to version of the program?
Let's take an address book. From program versi...
Is there any equivalent function of memset for vectors in C++. (Not clear() or erase() method, I want to retain the size of vector, I just want to initialize all the values)
...
Hello all,
Using g++ and having linker errors. I have a simple program in split into two modules: main.cpp and Dice.h Dice.cpp.
main.cpp:
#include <iostream>
#include "Dice.h"
int main(int argc, char **argv) {
int dieRoll = Dice::roll(6);
std::cout<<dieRoll<<std::endl;
std::cin.get();
return 0;
}
Dice.h:
#ifnde...
I have looked at the following software tools:
Ragel
ANTLR
BNF Converter
Boost::Spirit
Coco/R
YACC
ANTLR seems the most straight-forward, however its documentation is lacking.
Ragel looks possible, too, but I do not see an easy way to convert BNF into its syntax.
What other tools are available that can take BNF input and generate a ...
Hello,
I thought i'd post a little of my homework assignment. Im so lost in it. I just have to be really efficient. Without using any stls, boosts and the like. By this post, I was hoping that someone could help me figure it out.
bool stack::pushFront(const int nPushFront)
{
if ( count == maxSize ) // indicates a full array
...
I am playing with the registry programmatically for the first time, and it's not working that well (but at least I haven't destroyed my computer). Specifically, I keep getting back Error 5 (Access is Denied) from RegCreateKeyEx and RegSetValueEx. The thing that is strangest to me is that when HKEY_CURRENT_USER\Software\dir1\Sub Directory...