What is the best library for databases

Hi,
i'm now member here. And i have some questions.

1. What is the best library for databases? i tried MySQL++ is it the best?
2. What is the deference between the two codes blew?
3. How to compile the final program to be used in any platform?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

using namespace std;

int main ()
{

	int x = 1;

	if(x == 1){
		// do something. 
	}


}


1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

using namespace std;

int main ()
{


	if (1 == x){
		// do something.
	}

}



Because i saw a lot of people here using the next code!. I think there is no deference .


Sorry about my noobe questions.

Last edited on
You really should just ask one question per thread!

1. What is the best library for databases? i tried MySQL++ is it the best?

Depends on what you want to do -- MySQL++ is good if you want to work with MySQL databases. But not if you want to work with other types of SQL database (or non-SQL databases, for that matter.)

2. What is the deference between the two codes blew?

Assuming the omission of the variable declaration is a mistake (this means the second version will not compile, which is a difference!), I assume you're talking about testing 1 == x rather than x == 1

From the point of view of the logic there is no difference; you will get the same answer in both cases.

What it is is a way to avoid making this mistake if(x = 1) (i.e. assignment rather than testing for equality.) It's impossible to do the reverse if(1 = x) /* compile error */, so the compiler will prevent you from making the mistake.

Not everyone (!) likes this approach, but I have to admit I use it quite a bit having picked up the habit from my very first team lead. It is known is some circles as "Yoda conditions".
http://en.wikipedia.org/wiki/Yoda_conditions

3. How to compile the final program to be used in any platform?

In short, if you are coding in C++ you will have to compile for each distinct platform; the same binary will not run on all systems.

When it comes to Linux a single binary will probably not even run on different distributions. And Windows and OS X will definitely require their own version of the binary.

If you work exclusively with cross-platform libraries you should be able to compile the different binaries from the same source code, though.

Andy
Last edited on
Topic archived. No new replies allowed.