From: Warren Young Date: April 18 2005 3:50pm Subject: Re: Can I use mysql++ this way? List-Archive: http://lists.mysql.com/plusplus/4257 Message-Id: <4263D74B.2050202@etr-usa.com> MIME-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit Å£ À¤ 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) : host(host), user(user), password(password) { .... > I can always see exception thrown out of libmysqlpp.so It's covered in the FAQ: http://tangentsoft.net/mysql++/#faq