c++

How do you convert an IPhone OSStatus code to something useful!?

I am getting more than a little sick of this iphone sdk and it's documentation... I am calling AudioConverterNew in the documentation under Returns: it says "returns a status code" ... really... so far, through playing around with the parameters I have only been able to get two different errors neither of which are listed at the botto...

Returning an iterator to an element in STL Container

how would you check if the iterator that was returned by the function points to something in container class? ...

Is there any advantage of using map over unordered_map in case of trivial keys?

A recent talk about unordered_map in C++ made me realize, that I should use unordered_map for most cases where I used map before, because of the efficiency of lookup ( amortized O(1) vs. O(log n) ). Most times I use a map I use either int's or std::strings as keys, hence I've got no problems with the definition of the hash function. The ...

#include confusion and classes

I have been making several games with the Allegro API and C++. I have also been putting all my classes in 1 big main.cpp file. I tried many times to make .h and .cpp files, but my big problem is I have trouble with #including at the right place. For example, I want all my classes to access the allegro library without #including allegro.h...

How to set up gdb watchpoints in a program consisting of many files in C++ ?

I am trying to set up a watchpoint to monitor a variable in a package consisting of many C++ files. There are many files abc.cpp qwe.cpp .. xyz.cpp and so on I want to monitor a variable 'temp' in some function qwerty() in the file abc.cpp How do I set the watchpoint ? I tried watch abc.cpp::temp watch abc.cpp:temp watch temp but...

What's the best book to learn programming MySql from C/C++ ?

Not a generic introduction to MySql. I have one of those and also a PHP & MySql book. What's a good one to learn the C/C++ API? Or do I even need a book for that? Maybe it would be overkill? ...

Function template specialization importance and necessity

I read C++ Primer, and it says function template specialization is an advanced topic, but I am totally lost. Can anybody offer an example why function template specialization is important and necessary? Why don't function templates support partial specialization while class templates do? What's the underlying logic? ...

Scrolling ListView with mouse wheel occasionally negates scroll

I'm having some trouble with the Win32 listview, and I hope someone has some wisdom. When scrolling very quickly (via the wheel), occasionally, the listview appears to scroll, only to jump back to the selected item so it is in-view. In other words, the list undoes your wheel scroll to show you the selected item at the top/bottom of the l...

Using string functions (.substr) on arrays of strings

I have an array of strings, and need to grab substrings (the strings in between commas, in this case) and put them into another array of strings. I declare it as strings[numberOfTapes], so when I am searching for the commas I go character by character in a nested for loop, like so: for(int j = 0; j < tapes[i].length(); j++){ if(tap...

Reverse C-style String? - C++

Hi, I've written a small program for my programming class, that uses pointers to reverse a char array. I was wondering if there is anything that I should do differently? Am I doing this correctly? Is there a more efficient way to accomplish this? Thanks! My small program: int main ( ) { char buffer[80]; PrintHeader(); cout << "\nStr...

Best way to control user interface

What is the best way to control the user interface on linux using C++ program. I need to be able to move the mouse, enter text, and view the screen. ...

Least Squares Regression in C/C++

How would one go about implementing least squares regression for factor analysis in C/C++? ...

Mac vs. Ubuntu for C/C++ development?

I'm looking to buy a personal machine for development and I'm deciding whether to go with a Mac or a PC (on which I'd run Ubuntu). My plans for the next year or so involve getting more heavily into C/C++ and networking than I currently am. Are there any differences I should be aware of between the two OSes as far as C/C++ system librar...

Extern structure in C...

How to extern structure in c language. So that I can use a structure into b. ...

Is the following valid C++ code?

If it is, what is it supposed to do? typedef struct Foo_struct{ Dog d; Cat* c; struct Foo_struct(Dog dog, Cat* cat){ this->d = dog; this->c = cat;} } Foo; (back story: porting a program written in Visual C++ (on Windows) to g++ (on MacOSX); no idea what this code is suppoesd to do). Thanks! ...

How to get string from an address?

I have a ULONG value that contains the address. The address is basically of string(array of wchar_t terminated by NULL character) I want to retrieve that string. what is the best way to do that? ...

memory questions, new and free etc. (C++)

Hi, I have a few questions regarding memory handling in C++. What's the different with Mystruct *s = new Mystruct and Mystruct s? What happens in the memory? Looking at this code: struct MyStruct{ int i; float f; }; MyStruct *create(){ MyStruct tmp; tmp.i = 1337; tmp.j = .5f; return &tmp; } int main(){ ...

What are the pros and cons of using Matrices, Euler Angles, and or Quaternions for rotation representation?

Matrices and Euler angles can suffer from Gimbal lock but what are some other arguments for using one over the other? What do you think DirectX favors? What do you use in daily C++/C/DirectX programming? ...

Purpose of #ifndef FILENAME....#endif in header file

I know it to prevent multiple inclusion of header file. But suppose I ensure that I will include this file in only one .cpp file only once. Are there still scenarios in which I would require this safe-guard? ...

What's the best alternative library to gettimeofday() in C++?

Hi, Is there a more Object Oriented alternative to using gettimeofday() in C++ on linux? I like for instance to be able to write code similar to this: DateTime now = new DateTime; DateTime duration = new DateTime(2300, DateTime.MILLISECONDS) DateTime deadline = now + duration; while(now < deadline){ DoSomething(); delete now;...