c++

LSB link error possibly related to Qt

I am converting a large application to compile with lsbc++. I do not aim for full LSB compliance, I just want it to work with all but one of the LSB4.0 distributions (the remaining distribution is RHEL3 and lacks 100s of interfaces I use). The current situation is that I am missing one symbol in one library (of about 40 libraries/executa...

static members and LNK error in C++

Hi, I have a class that has a static member, which I want to use in the class constructor, but the code doesn't compile, and I'm left with these errors: "fatal error LNK1120: 1 unresolved externals" "error LNK2001: unresolved external symbol "protected: static class Collection A::collection" Any help will be appreciated. Thanks. "a.h...

Manage falling using rays in Irrlicht

In my game i'm currently working on, i only need very basic physics, so i don't want Newton, ODE, Bullet or similar. I basically only want to fall as long as no node (all equally sized blocks) is beneath me. I tried to send a ray from the camera and 100.0 units downwards. But it gives false positives. selectedNode = NULL; //Falling...

Searching childs

Hello I have class A. Class A is responsible for managing the lifetime of B objects and it contains container of B objects that is map<BGuid,B>, and each B object contains container of C objects which is map<CGuid,C>.I have one global A object for the entire application. I have the following problem: I have CGuid object and I want to u...

Is using namespace..like bad?

Possible Duplicate: Why is 'using namespace std;' considered a bad practice in C++? Every time I use using namespace std I always get that "thats a terrible programming habit". Now I'm graduating this December with my B.S. in C.S. but I don't claim to know everything, but no one has ever explained why this is so bad. I underst...

Is there a solution for Floating point Arithmetic problems in C++ ?

I am doing some floating point arithmetic and having precision problems. The resulting value is different on two machines for the same input. I read the post @ http://stackoverflow.com/questions/3031143/why-cant-i-multiply-a-float and also read other material on the web & understood that it is got to do with binary representation of floa...

Extract a struct member from an array of structs

I have an array of structures that contain multiple variables: struct test_case { const int input1; //... const int output; }; test_case tc[] = { {0, /**/ 1}, // ... {99, /**/ 17} }; int tc_size = sizeof(tc) / sizeof(*tc); and I want to extract a vector of the outputs so I can compare them to another array...

Is there a better alternative to an STL comparator with state?

I have a fairly large, sophisticated algorithm that uses a std::priority_queue. In some cases, I want the queue to be a min-queue, and in others, a max-queue. So I have to provide a comparator type that does one or the other. Since the comparator is a template parameter, it is fundamentally part of the type of the std::priority_queue....

Translate C++ Constructor into Java

I'm working on translating a small package from C++ to Java. I've never really used C++, so some of the syntax is a bit of a mystery. In particular, I'm having difficulty working out what the Java equivalent to this would be: file: SomeClass.cpp SomeClass::SomeClass( BitStream* data, const char* const filename ) : data( data ), cip...

Problem with DEVMODE.dmCopies field.

Hi. I'm writing a printing application and i having trouble with dmCopies field of DEVMODE structure. This field specifies number of document copies printed. When i print multipage document (two pages and more) - setting up dmCopies works fine, but when one-page document printed dmFields ignored. First i think that problem in my applicat...

How can I initialise a static member of a class after certain other initialisation has taken place?

I want to be able to initialise the static member scalingfactor in the following class: class ScalingRect: public Rect { public: static float scalingfactor; ... }; I thought I'd initialise it using a static member function of another class like this in the .cpp float ScalingRect::Rect = Engine::GetScaleFactor(); However, I...

passing a string literal to a function that takes a std::string&

I have the following function void AddNodeValue(XMLNode& node, std::string& value); I want to use it like this: document.AddNodeValue(modvalue,"modvalue"); and the compiler complains: error C2664: 'void XML::XMLDocument::AddNodeValue(XML::XMLNode &,std::string &)' : cannot convert parameter 2 from 'const char [9]' to 'std::stri...

How Many default methods does a class have?

Sorry, this might seem simple, but somebody asked me this, and I don't know for certain. An empty C++ class comes with what functions? Constructor, Copy Constructor, Assignment, Destructor? Is that it? Or are there more? ...

is `x-- > 0 && array[x]` well defined behavior in c++?

can i use x on both sides of a boolean expression when I post-increment it on the left side? the line in question is: if(x-- > 0 && array[x]) { /* … use x … */ } is that defined through the standard? will array[x] use the new value of x or the old one? ...

C++ - Undefined reference issues when working with classes

Hello, everyone, I am working on a small project where I use multiple classes. One of those classes is Menu, which has a showContainer method. Here's the class declaration: class Menu { //snip Menu(); Menu(std::string, std::string, int, int); virtual ~Menu(); //snip /** * Visualiza e providencia navegacao p...

can i check in C(++) if an array is all 0 (or false)?

can i check in C(++) if an array is all 0 (or false) without iterating/looping over every single value and without allocating a new array of the same size (to use memcmp)? i'm abusing an array of bools to have arbitrary large bitsets at runtime and do some bitflipping on it ...

CGAL Newbie Question: Which segments intersect?

Hi, i'm having a set of segments (each defined with two points; 2D) and want to know for every segment x, how many other segments y1,..., yn are intersecting x. How would you do that efficiently in CGAL? I don't have any experience with the CGAL library and Computer Geometry at all. I just need an algorithm for doing the stuff mentione...

How to interpret a custom language

Hi I have an app in C++ which actually processes a binary file. The binary file is a collection of events say A/B/C, and on detecting event A in the file, the app handles the event in "handler A". Now i need to write another script in a custom language, which gets executed orthogonally to the binary file processing. The script can hav...

Am I missing anything here in my statement about c++?

You can't have code outside of functions except for declarations, definitions and preprocessor directives. Is that statement accurate, or is there something I'm missing? I'm teaching my nephew to program, and he was trying to put a while loop before main. He's pretty young, I want to give him a hard simple rule that he can understand....

c++ for_each() and object functions

I have an assignment that is the following: For a given integer array, find the sum of its elements and print out the final result, but to get the sum, you need to execute the function for_each() in STL only once (without a loop). As of now this is my code: void myFunction (int i) { cout << " " << i << " " << endl; } int main() { ...