c++

Floating-point for ARM in Visual C++

I'm using Visual C++ 2005 for building applications for ARM, Qualcomm Snapdragon chip. I know it supports VFPv3. Where can I get SDK or something like to use floating-point arithmetics hardware? Best of all if Visual C++ compiler would generate VFP instructions instread of emulating. ...

Copy elision on Visual C++ 2010 Beta 2

I was reading 'Want Speed? Pass by Value' on the C++ Next blog and created the following program to get a feel for copy elision and move semantics in C++0x: http://pastebin.com/f39c826c6 However I am perplexed by one thing. Here is the output I get when compiled in release mode on Visual C++ 10.0 (Beta 2): Move assign from RVO: ...

How do STL containers copy objects?

I know STL containers like vector copies the object when it is added. push_back method looks like: void push_back ( const T& x ); I am surprised to see that it takes the item as reference. I wrote a sample program to see how it works. struct Foo { Foo() { std::cout << "Inside Foo constructor" << std::endl; } Foo...

Fastest way to write large STL vector to file using STL

I have a large vector (10^9 elements) of chars, and I was wondering what is the fastest way to write such vector to a file. So far I've been using next code: vector<char> vs; // ... Fill vector with data ofstream outfile("nanocube.txt", ios::out | ios::binary); ostream_iterator<char> oi(outfile, '\0'); copy(vs.begin(), vs.end(), oi); ...

How dynamic casts work?

Let's say I have type A, and a derived type B. When I perform a dynamic cast from A* to B*, what kind of "runtime checks" the environment performs? How does it know that the cast is legal? I assume that in .Net it's possible to use the attached metadata in the object's header, but what happen in C++? ...

Declaring an array whose size is declared as extern const

I have a problem initializing an array whose size is defined as extern const. I have always followed the rule that global variables should be declared as extern in the header files and their corresponding definitions should be in one of the implementation files in order to avoid variable redeclaration errors. This approach worked fine ti...

Overloading operator >

Hello, In my homework, I have to design a class Message; among other attributes, it has attribute "priority" (main goal is to implement priority queue). As in container I must check if one object is greater than other, I have overloaded operator '>'. Now, I have a few general questions about it... Question one: If I overload operato...

Tool for program statistics

Is there a tool which is able to parse my source code (fortran, C or C++) and return statistics such as the number of loops, the average loop size, the number of functions, the number of function calls, the number, size and type of arrays, variables, etc ? Something similar to this which does not run easily on my architecture ...

Undefined symbols. ld: symbol not found

Everything is working except this undefined symbols error: bash-3.2$ make g++ -Wall -g solvePlanningProblem.o Position.o AStarNode.o PRM.o PRMNode.o Worl.o SingleCircleWorld.o Myworld.o RECTANGLE.o CIRCLE.o -o solvePlanningProblem `Undefined symbols: "Obstacle::~Obstacle()", referenced from: Myworld::~Myworld()in Myworld.o ...

alutCreateBufferHelloWorld () in openal

hi all i need your help again in programing the openal i am new in programing in general >>and start to learn openal by vc++ 6 and i am learning it from the doc that attachment with sdk1.1 and have this program #include <conio.h> #include <stdlib.h> #include <stdio.h> #include <al.h> #include <alc.h> #include <alut.h> #pragma commen...

StAX Writer Implementation for C/C++

Are there any other STaX Writer implementation for C/C++ except libxml2? ...

Bitflag enums in C++

Using enums for storing bitflags in C++ is a bit troublesome, since once the enum values are ORed they loose their enum-type, which causes errors without explicit casting. The accepted answer for this question suggests overloading the | operator: FlagsSet operator|(FlagsSet a, FlagsSet b) { return FlagsSet(int(a) | int(b)); } ...

What are the best RSS feeds for C++ ?

What are the best RSS feeds for C++ ? ...

Undefined symbols "vtable for ..." and "typeinfo for..." ?

Nearly the final step but still some strange erros.... bash-3.2$ make g++ -Wall -c -g Myworld.cc g++ -Wall -g solvePlanningProblem.o Position.o AStarNode.o PRM.o PRMNode.o World.o SingleCircleWorld.o Myworld.o RECTANGLE.o CIRCLE.o -o solvePlanningProblem Undefined symbols: "vtable for Obstacle", referenced from: Obstacle::Obstac...

Problem with priority_queue - Writing memory after heap

Hello again, I am trying to use priority_queue, and program constantly fails with error message HEAP CORRUPTION DETECTED. here are the snippets: class CQueue { ... priority_queue<Message, deque<Message>, less<deque<Message>::value_type> > m_messages; ...}; class Message has overloaded operators > and < Here I fill up ...

C++: pass variable by value

This is the situation: int f(int a){ ... g(a); ... } void g(int a){...} The problem is that the compiler says that there is no matching function for call to g(int&). It wants me to pass the variable by reference and g() recieves parameters by value. How can I solve this? ...

Type Casting C++

see the following code: void simple_dynamic_casts( ) { AB ab; B* bp = (B*)&ab; // cast needed to break protection A* ap = &ab; // public derivation, no cast needed AB& abr = dynamic_cast<AB&>(*bp); // succeeds ap = dynamic_cast<A*>(bp); assert( ap != NULL ); bp = dynamic_cast<B*>(ap); assert( b...

Rotating coordinates around an axis

I'm representing a shape as a set of coordinates in 3D, I'm trying to rotate the whole object around an axis (In this case the Z axis, but I'd like to rotate around all three once I get it working). I've written some code to do this using a rotation matrix: //Coord is a 3D vector of floats //pos is a coordinate //angles is a 3d vector...

Templates and nested classes/structures

I have a simple container : template <class nodeType> list { public: struct node { nodeType info; node* next; }; //... }; Now, there is a function called _search which searches the list and returns a reference to the node which matched. Now, when I am referring to the return-type of the...

How come we pass the linking stage and still miss symbols ? ?

Hi All And thanks in advance. operating system: AIX 5.3. compiler: xlC_r build system is: "Unix Makefiles" our application uses several static (.a) libs and several shared (.so) libs. the build process pass successfully (we do get some duplicate symbol warnings). but when we try to execute we are getting symbol missing errors. Note:...