List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:April 18 2005 3:50pm
Subject:Re: Can I use mysql++ this way?
View as plain text  
牛 坤 wrote:

> #define MAX 20
> class Connect
> {
>  private:
>    char host[ MAX ];

A transplant to C++ from C, I see.  Consider using string here instead.
 Fixed-length character arrays are *so* 1990...

>    Connect( char host[] = NULL, char user[] = NULL, char password[] = 
> NULL )

It's more accepted in C++ to use 0 instead of NULL.

>        this -> host = host;

It's extremely rare to ever need to use the 'this' pointer.  You
certainly don't need to use it to access member variables.  In this
particular instance, you need it because you've named some parameters
the same as some class members, but you can avoid even this use of the
'this' pointer by using C++ initializer lists:

	Connect(char* host = 0, char* user = 0, char* password = 0) :

> I can always see exception thrown out of

It's covered in the FAQ:
Can I use mysql++ this way?牛 坤18 Apr
  • Re: Can I use mysql++ this way?Warren Young18 Apr
Re: Can I use mysql++ this way?Tommy18 Apr