c++

Microsoft objects, the Release() functions return value?

I'm curious because I couldn't find out about this on MSDN. I've found the Release() function is present in various COM objects which I'm obviously supposed to use for deleting pointers. But I'm not sure what does it return exactly? I used to think it would return the number of references which still exist to the object remaining, theref...

How do you link a .lib file without putting them into the compilers library folder?

Is there a way in my code that I can link to the library files I need so that I do not have to setup each individual compiler I use? I want to be able to use Visual C++.net 2005, G++, etc. I am trying to make a cross platform game engine, but some platforms use a custom compiler and I want to make my engine as versatile as possible. ...

iterator vs reverse_iterator

Hi, I'm using std::map to store a lot of elements (pairs of elements) and I have a "little" doubt, what is more efficient to iterate all elements over my std::map, iterator or reverse_iterator? Thank's. Salu2. ...

How to make sure you have overriden (hide) a method in a derived class in C++?

class Base { public: void foo() const { std::cout << "foo const" << std::endl; } }; class Derived : public Base { public: void foo() { std::cout << "foo"<< std::endl; } } I want to make sure that foo() const is correctly hidden for Base. Yeah, this is a bad i...

Markdown Implementations for C/C++

What is the best implementation of Markdown for C or C++? I found these via Google, and would appreciate comments about which ones work well and which ones don't (and which ones I may have missed): peg-markdown Discount Cpp-Markdown ...

Why C++ compiler (gcc) thinks function is `virtual' field?

I have a the following method definition in my class: virtual Calc* Compile( Evaluator* evaluator, ResolvedFunCall* fun_call, string* error); For some reason, GCC complains that: error: 'Compile' declared as a 'virtual' field Any ideas why it would believe Compile to be a field, instead of a method? ...

C++ - How to know if there is no returned value from a map::upper_bound() ?

Hi, I've got a very simple map : std::map<int, double> distances; distances[20.5] = 1; distances[19] = 2; distances[24] = 3; How do i know if there isn't any returned value, when using a map::upper_bound() in this case for example: std::map<int, double>::iterator iter = distances.upper_bound(24); (24 is the max key so an unexpecte...

PHP/Rails/Django/ASP websites should have been written in C++?

I was looking at a SO member's open source project. It was a web framework written in C++. Now you are all probably ready to respond about how C++ is a horrible language to do websites in, and that in websites, the bottleneck is in the database. But... I read this post: http://art-blog.no-ip.info/cppcms/blog/post/42 and in there he m...

Explode function in C++.

I am new to programming. I have been trying to write a function in C++ that explodes the contents of a string into a string array at a given parameter, example: string str = "___this_ is__ th_e str__ing we__ will use__"; should return string array: cout << stringArray[0]; // 'this' cout << stringArray[1]; // ' is' cout << stringArra...

How to Learn C++ When you are stuck in your ways with newer Languages?

Possible Duplicates: What is the best approach for a Java developer to learn C++ How would you go about learning C++ if you were "Stuck in your ways" with newer languages like Java or C#? I've been working as a developer for 3 years, I've got both a Bachellors and a masters in computing science from a Reputable UK University......

Given date and time, how do you get the Epoch time?

I have int year, month, day, hour, min, sec How can I get the epoch time in C++? I am having difficulty figuring it out using Boost, any examples or alternative ways to do it? ...

How to sort an object std::vector by its float value

I have a C++ std::vector denoted as: std::vector<GameObject*> vectorToSort; Each object in vectorToSort contains a float parameter which is returned by calling "DistanceFromCamera()": vectorToSort.at(position)->DistanceFromCamera(); I wish to sort the vector by this float parameter however std::sort does not appear to be able to do...

Prompting a user for the filename or directory

I'm prompting the user for a filename, if they enter a valid filename the first time, it works. However, if its invalid the first time, every other check fails. How would I fix this? Also, let's say they just specify a directory, how would I get the names of all the text files and how many there are? int main() { ifstream inFile; ...

How to overload the indirection operator? (C++)

I'm trying to create an iterator class as a member-class for a list class, and am trying to overload the indirection operator (*) to access the list it's pointing to: template<class T> T list<T>::iterator::operator*(iterator& iter) { return ((iter.lstptr)->current)->data; } where lstptr is a pointer to a list, current is a pointer...

uint64 UTC time

I have a UTC date time without the formatting stored in a uint64, ie: 20090520145024798 I need to get the hours, minutes, seconds and milliseconds out of this time. I can do this very easily by converting it to a string and using substring. However, this code needs to be very fast so I would like to avoid string manipulations. Is there ...

Portable way to find out if a command exists (C/C++)

C standard library provides functions system and popen to run a command. But is there a portable way to detect if a command exists? ...

Using escaped_list_separator with boost split

I am playing around with the boost strings library and have just come across the awesome simplicity of the split method. string delimiters = ","; string str = "string, with, comma, delimited, tokens, \"and delimiters, inside a quote\""; // If we didn't care about delimiter characters within a quoted section we could us vector<s...

boost::shared_ptr use_count

I'm trying to understand what's going on in the following code. When object-a is deleted, does it's shared_ptr member variable object-b remains in memory because object-c holds a shared_ptr to object-b? class B { public: B(int val) { _val = val; } int _val; }; class A { public: A() { _b = n...

Can't push_front() a standard library list with my objects in C++

I have an class and I would like to use the standard library list to store a list of them. I essentially want to push_front() the list. So my code is like this: #include <list> /* ... lots of stuff ...*/ complexNode myObject(); std::list<complexNode> complexList(); myList.push_front(myObject); But the compiler throws this error: e...

In C++, which is the way to access a 2D array sequentially (memory block wise)

Edit: I've removed the faster/more efficient from the question title as it was misleading..my intention was not optimisation but understanding arrays. Sorry for the trouble! int array[10][10], i, j; for(i=0;i<10;i++) { for(j=0;j<10;j++) std::cin>>array[i][j]; } Versus int array[10][10], i, j; for(i=0;i<10;i++) { for...