c++

How do i add a mclmcrrt.lib or (.lib) file when compiling with g++ Compiler

I have a algorithm code which uses matlab library(mclmcrrt.lib) it compiles well in my vc++ compiler when i add that library to it. My question is if i want to compile it on Linux g++ compiler how should i link the library can i use it? ...

Template class won't build properly

Header class linkNode { public: linkNode(void *p) { before = 0; after = 0; me = p; } linkNode *before; void *me; linkNode *after; }; template <class T> class list { public: list(void) { first = last = NULL; size = 0; } ~...

Can I write the contents of vector<bool> to a stream directly from the internal buffer?

I know vector< bool > is "evil", and dynamic_bitset is preferred (bitset is not suitable) but I am using C++ Builder 6 and I don't really want to pursue the Boost route for such an old version. I tried : int RecordLen = 1; int NoBits = 8; std::ofstream Binary( FileNameBinary ); vector< bool > CaseBits( NoBits, 0 ); Binary.write( ( const...

Why is event handling in native Visual C++ deprecated?

http://msdn.microsoft.com/en-us/library/ee2k0a7d.aspx Event handling is also supported for native C++ classes (C++ classes that do not implement COM objects), however, that support is deprecated and will be removed in a future release. Anyone knows why? Couldn't find any explanation for this statement. ...

Using OpenCV 2.0.0a with dev c++

OpenCV 2.0.0a is very different to the older version of OpenCV and so is very different to setup. I have tried to set it up for Visual C++ Express 2008 but to no avail so I wanted to ask whether anyone has got it to work on Dev C++ and if yes can they tell me how. ...

Visual Studio 2010 and boost::bind

I have this simple piece of code that uses boost::bind: #include <boost/bind.hpp> #include <utility> #include <vector> #include <iterator> #include <algorithm> int main() { std::vector<int> a; std::vector<std::pair<bool,int> > b; a.push_back(1); a.push_back(2); a.push_back(3); std::transform(a.begin(), a.end()...

performance: sorting 'm' vectors with N/m elems Vs sorting single vector with N elements

Operation A I have N vectors, each containing certain number of unique 3D points. For Example : std::vector<double*> vec1; and like that I am performing sort operation on each of the vector like: std::sort(vec1.begin(), vec1.end(), sortCriteria()); std::sort(vec2.begin(), vec2.end(), sortCriteria()); std::sort(vec3.begin(), vec3.en...

File version information

How can I add version information to a file? The files will typically be executables, .so and .a files. Note: I'm using C++, dpkg-build and Ubuntu 8.10 if any of those have support for this. ...

Non static members as default parameters in C++

I'm refactoring a large amount of code where I have to add an extra parameter to a number of functions, which will always have a value of a member of that object. Something like class MyClass { public: CMyObject A,B; void MyFunc(CMyObject &Object); // used to be void MyFunc(); }; Now, I'd actually like it to read class MyC...

Array of classes. Stack or heap?

class temp; temp *t; void foo() { temp foo2; t[1] = foo2; } int main() { t = new temp[100]; foo(); //t[1] is still in memory? } If i want an array of classes like this, am i going to have to use pointer to pointer? (and use 'new' on each element in the array) E.G: temp **t; if i want to make an array of 100 ptr to ptr...

C++ MiniDumpWriteDump - FullMemoryDump doesn't give me much information

Hi, I've been using MiniDumpWriteDump to generate dump files on a crash. I've been trying to do a full memory dump. This seems to work, and generates a large file as expected. However when I load this huge file into Visual Studio (2005) I don't seem to be able to see the values of any variables on the heap. In fact it gives me no more ...

Using istringstream to process a memory block of variable length

I'm trying to use istringstream to recreate an encoded wstring from some memory. The memory is laid out as follows: 1 byte to indicate the start of the wstring encoding. Arbitrarily this is '!'. n bytes to store the character length of the string in text format, e.g. 0x31, 0x32, 0x33 would be "123", i.e. a 123-character string 1 byte s...

When object is contructed statically inside a function, would it be allocated on the heap or on the stack?

if i have the following code: for (...) { A a; } would a be allocated on the heap or on the stack? ...

DRYing c++ structure

I have a simple c++ struct that is extensively used in a program. Now I wish to persist the structure in a sqlite database as individual fields (iow not as a blob). What good ways are there to map the attributes of the struct to database columns? ...

Problem with iterators

Basically I wrote some code to print out a triangle recursively - and originally I used an iterator in the code to take the inner parts of a triangle and include them in the complete 'picture'. Anyway here's the code: #include <iostream> #include <string> #include <vector> using namespace std; vector<string> print_triangle( int max_...

Calling temporary object’s methods gives compiler error with older c library.

Hi everybody! I have a strange problem with my code when porting from a computer with glibc-2.5-25 (suse 10.2) to a computer with glibc-2.3.2-6 (suse 8.2). I use several method calls on temporary objects and they are not working on the older machine. class A { public: A(int n) {} void method() {} }; int main() { A(10).meth...

Calling WNetAddConnection2 with empty local name

I have a small program that simply checks if a specified file is located on a specified network drive that is not mapped on the computer. To check this I temporarily map to the network location, check if the file exists and than unmap the drive. I now figured out that I can call WNetAddConnection2 with an empty local name (MSDN: If the s...

TinyXML can't read its own file

Hello there! I'm currently working on a C++ MFC project on visual studio 2003. The aim of this project is to be able to take an XML file containing language data, convert it to a simple CSV file and back to XML. To do this, I'm using the TinyXML library, which is simple and good enough for my needs. The problem is that, once I try to c...

Release management system for Linux

What we need in our firm is a sort of release management tool for Linux/C++. Our products consist of multiple libraries and config files. Here I will list the basic features we want such system to have: Ability to track dependencies, easily increase major versions of libraries whose dependencies got their major version increased. It sh...

Typedeffing a function (NOT a function pointer)

typedef void int_void(int); int_void is a function taking an integer and returning nothing. My question is: can it be used "alone", without a pointer? That is, is it possible to use it as simply int_void and not int_void*? typedef void int_void(int); int_void test; This code compiles. But can test be somehow used or assigned to som...