c++

Beginner questions regarding to "building a library", in Xcode on iPhone specifically.

Hi, I have never been clearly understand all these linking/building/dependency business. Now, I am trying to build the FreeType library (which is in C++), into the *.a library file for the iPhone (because another library I am trying to use, openFrameworks, would depend on FreeType). I know that to compile C++ with iPhone I simply need ...

How to delay the initialisation of a member in a C++ base class until the ctor of derived class is executed?

Here's the scenario: I want define a base class that allocate some buffer once for all derived classes, while the size of the buffer varies among different derived classes. I could achieve it in this way: class base { public: base():size(), p_array(0){} private: size_t size; boost::shared_array<unsigned char> p_array; };...

12 Digit Unique ID - Code reliability

Guys, I wanted a number that would remain unique for a day (24 hours). Following is the code that I came up with; I was wondering about its fallacies/possible risks; 'I believe' this guarantees a 12 digit unique number for a day atleast. Logic is to get the current date/time (hhmmssmmm) and concat the first four bytes of query perform...

Silverlight with C++.Net

Hi, Can you use C++.Net for writting a Silverlight application? Not use C# or VB.Net as the backend language but C++.Net ...

msvcp80d.dll not found while using TBB

I am using Intel TBB C++ for multithreading an application on visual studio 2008. When I run the executable I get a dialog saying "MSVCP80D.dll" was not found. There is so much on the net about this that it confuses me. Please help. EDIT: Based on answers, finally I was able to fix the "dll missing" problem. I had given a path to TBB...

Law of demeter or return the whole vector

Which one is better: public: const vector<int> & GetPointsVector(); private: vector<int> PointsVector; Or: public: int GetCurrentPoint(); void MoveToFirstPoint(); void MoveToNextPoint(); bool IsAtLastPoint(); size_t GetNumberOfPoints(); private: vector<int> PointsVector; ...

How to guarantee a function will not be entered again if it does not return within a thread?

I don't want the function to be entered simultaneously by multiple threads, neither do I want it to be entered again when it has not returned yet. Is there any approach to achieve my goal? Thank you very much! ...

functors_sort:vector

I have this class: class QSweep{ public: QSweep(const vector< vector<double> >& myPoints, const vector< vector<int> >&myEdges); void intersection(vector< vector<double> >& myPoints, vector< vector<int> >& myEdges); vector< vector<int> >* sortEdges(vector< vector<double> >& myPoints, vector<vector<int>>& myEdges); bool sortx(const vec...

cpp iterator problem

template<class T> class mStack { private: vector<T> a; vector<T>::iterator top; public: void push(T); T pop(); mStack(); void printStack(); }; The code with above class is not getting compiled... why? What is the problem? The compiler says "expected ; above top". ...

How to print a Qt dialog or window?

How do I get Qt to print a complete dialog or window? I could dump the window contents with an external program like xwd and print that, but I would prefer to do it all with Qt. ...

How to get Vector of Complex numbers from two vectors (real & imag)

Hi, I have two vectors of floats and i want them to become one vector of Complex numbers. I'm stuck. I don't mind using iterators, but i am sure it'd be rediscovering the wheel i'm not informed about. Is my code leading me in the right direction? typedef std::vector<float> CVFloat; CVFloat vA, vB; //fil vectors typedef std::complex<CVFl...

How to use 2 C libs that export the same function names

Duplicate of the following question: C function conflict Hi, in my current project I have to use some kind of interface lib. The function names are given by this interface, what this functions do is developers choice. As far as I can tell a project shall use this functions and when it comes to compiling you choose the lib and with it ...

Writing files to USB stick causes file corruption/lockup on surprise removal

I'm writing a background application to copy files in a loop to a USB stick with the "Optimize for quick removal" policy set. However, if the stick is removed part way through this process (specifically in the WriteFile() call below, which returns ERROR FILE NOT FOUND) the application hangs, the drive is then permanently inaccessible fro...

In C++, how can I avoid #including a header file when I need to use an enumeration?

In my C++ header files I try to use forward declarations (class MyClass;) instead of #including the class header, as recommended in many C++ coding standards (the Google C++ Style Guide is one). Unfortunately, when I introduce enumerations, I can't do the forward declaration any more. Like this: //// myclass1.hpp //// class MyClass1 {...

C++ enum not properly recognized by compiler

Can anyone explain why the following code does not compile (on g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-49))? struct X { public: enum State { A, B, C }; X(State s) {} }; int main() { X(X::A); } The message I get is: jjj.cpp: In function 'int main()': jjj.cpp:10: 'X X::A' is not a static member of 'struct X' jjj.cpp:10...

A C++ book that covers non syntax-related problems

I'm looking for a book focusing on non-syntax related C++ problems. IMHO majority of C++ books are covering syntax or small "horizon" problems (like: the best way to assign values to the std::vector). I currently know one such book: Large Scale C++ Design (John Lakos). What do you think about this book? Please include other books matc...

What do I get from front() of empty std container?

If front () returns a reference and the container is empty what do I get, an undefined reference? Does it mean I need to check empty() before each front()? ...

2D matrix and overloading operator() / ugly syntax

I'm using a 2D matrix in one of my projects. It's something like it is suggested at C++ FAQ Lite. The neat thing is that you can use it like this: int main() { Matrix m(10,10); m(5,8) = 106.15; std::cout << m(5,8); ... } Now, I have a graph composed of vertices and each vertex has a public (just for simplicity of the example)...

Equivalent of IllegalArgumentException of Java in C++

In Java if an input argument to a method is invalid, we can throw an IllegalArgumentException (which is of type RuntimeException). In C++, there is no notion of checked and unchecked exceptions. Is there a similar exception in standard C++ which can be used to indicate a runtime exception? Or is there a common style not in the standard b...

RSACryptoServiceProvider <-> CryptImportKey Equivalency

If I have a key created from a unmanaged app and If I want to import this key in a managed app and generate another key or encrypt it. Basically the same key will be imported/exported back and forth from managed and unmanaged code. Therefore what is the equivalent to CryptExportKey(hKey, hPublicKey, SIMPLEBLOB, 0, lpData, &nSize); a...