c++

Why does a pointer change itself during function transition?

In the following case I'm calling a Func with pointer passed to it, but in the called function, the parameter shows the pointer value as something totally bogus. Something like below. bool flag = Func(pfspara);--> pfspara = 0x0091d910 bool Func(PFSPARA pfspara) --> pfspara = 0x00000005 { return false; } Why does pfspara change t...

C or C++ BigInt library on Microsoft Windows

What arbitrary-precision integers (and or rationals) library are there for compilers running on Microsoft Windows, and which would you recommend? Please state license type / cost, supported compilers (i.e. GCC and or VC++) for the library. ...

C3681 identifier not found

Hi, i have two projects in CPP. one defines a function which i'd like to invoke from the other. i added reference to the first project. still i get the message of "identifier not found". assuming that the CPP file in the first project doesn't have a header, how do i make the second project know about its functions? thanks. ...

Checklist for writing copy constuctor and assignment operator in C++

Please write a list of tasks that a copy constructor and assignment operator need to do in C++ to keep exception safety, avoid memory leaks etc. ...

Do you prefer explicit namespaces or 'using' in C++?

When using C++ namespaces, do you prefer to explicitly name them, like this: std::cout << "Hello, world!\n"; Or do you prefer using namespace: using namespace std; cout << "Hello, world!\n"; And if if you prefer the latter, do you declare your usings at file or function scope? Personally I prefer to explicitly name them - it's mor...

C# invoking CPP function with unknown number of args from CPP

i have a function in CPP with the following prototype: char* complexFunction(char* arg1, ...); i import it from a C# using DLLImport attribute. the questions are: how do i define the prototype in the C# (under the DLLImport attribute)? how do i pass the arguments to this function? thanks ...

Scatter Plots in C++

What is the best way to graph scatter plots in C++? Do you write data to a file and use another tool? Is there a library like matplotlib in Python? ...

Error creating xercesc dom parser object

I am trying to create an Xercesc DOM Parser in my code and for some reason and try to instiate an XercescDOM object I get a NULL pointer returned. I am using xercesc version 2.8 Here the code. using namespace xercesc; int main(int argc, char*argv[]) { try { XMLPlatformUtils::Initialize(); } catch (const XMLException& e) { char*...

Better to return a C++ reference or a weak_ptr?

Suppose I have a class where I want the user to be able to have a reference to one of my members. Which is preferred? class Member; class ClassWithWeakPtr { private: boost::shared_ptr<Member> _member; public: boost::weak_ptr<Member> GetMember(); }; or class Member; class ClassWithCppReference { private: Member _member; pu...

What type for an integer of more than 4 bytes?

Hi, I have to use unsigned integers that could span to more than 4 bytes, what type should I use? PS Sorry for the "noobism" but that's it :D NB: I need integers because i have to do divisions and care only for the integer parts and this way int are useful ...

How can I force the deletion of locked files in C/C++?

How do I programmatically force the deletion of files that are locked by the operating system or any other program with C/C++? The functionality should be similar to the software "Unlocker" at http://ccollomb.free.fr/unlocker. ...

C++ Coding Guideline 102

If you were allowed to add another coding guideline to the 101 guidelines of the "C++ coding standards" (Herb Sutter and Andrei Alexandrescu), which would you add? ...

Requirement for key in std::multimap

I have a std::multimap where key is a custom class. Something like this: Class X { public: std::string s; int x; operator <(const X& other) const { return s < other.s; } }; std::multimap<X, int> mymap; Now, I'd like to use upper_bound and lower_bound to iterate over all elements with the same value of "s". Do I need to imp...

Python embedded in CPP: how to get data back to CPP

While working on a C++ project, I was looking for a third party library for something that is not my core business. I found a really good library, doing exactly what's needed, but it is written in Python. I decided to experiment with embedding Python code in C++, using the Boost.Python library. The C++ code looks something like this: #...

Variable naming schemes for objects in C++?

Hey everyone, I am implementing a BFS, and what it is going to do is go through an ordered tree to find the shortest solution to a puzzle. What i will be doing is creating a Snapshot object that holds the current position of each piece in a puzzle. I will add this Snapshot object into the queue and check if it is the solution. However,...

How do you properly use WideCharToMultiByte

I've read the documentation here: http://msdn.microsoft.com/en-us/library/ms776420(VS.85).aspx I'm stuck on this parameter: lpMultiByteStr [out] Pointer to a buffer that receives the converted string. I'm not quite sure how to properly initialize the variable and feed it into the function ...

Is there a good C++ crash reporting library that works well with Visual Studio 2005?

After reading this previous discussion and this one, it looked as though Crashrpt was exactly what I was looking for, but it seems it's no longer being maintained and, after playing with it, found it doesn't work well with Visual Studio 2005. Is anyone using Crashrpt with Visual Studio 2005? If not, can anyone recommend a good C++ solu...

Parsing integers from a line

I am parsing an input text file. If I grab the input one line at a time using getline(), is there a way that I can search through the string to get an integer? I was thinking something similar to getNextInt() in Java. I know there has to be 2 numbers in that input line; however, these values will be separated by one or more white spa...

Question about shallow copy in C++

Say I have a struct "s" with an int pointer member variable "i". I allocate memory on the heap for i in the default constructor of s. Later in some other part of the code I pass an instance of s by value to some function. Am I doing a shallow copy here? Assume I didn't implement any copy constructors or assignment operators or anythi...

Is there a max array length limit in C++?

Is there a max length for an array in C++? Is it a C++ limit or does it depend on my machine? Is it tweakable? Does it depend on the type the array is made of? Can I break that limit somehow or do I have to search for a better way of storing information? And what should be the simplest way? What I have to do is storing long long int o...