[prev in list] [next in list] [prev in thread] [next in thread]
List: mysql-plusplus
Subject: Re: Derive a structure and use it with storein
From: "=?ISO-8859-1?Q?Lo=EFc_Dardant?=" <loic.dardant () gmail ! com>
Date: 2008-07-02 13:03:59
Message-ID: 2b029a380807020603s1a0d383dq24babc45f47817a8 () mail ! gmail ! com
[Download RAW message or body]
Hi Warren Young,
You reach the right error. Unfortunately, I've tested the tool ssqls-pretty
to see what the macro produce and I saw lot of code but no constructor. I
don't know if it is a good suggestion, but maybe an example in the
documentation would be useful for other people.
Have a nice day, many thanks.
Loïc
2008/7/2 Warren Young <mysqlpp@etr-usa.com>:
> On Jul 2, 2008, at 3:56 AM, Loïc Dardant wrote:
>
> class User : public database::User
>> {
>> public:
>> User(mysqlpp::sql_varchar a, mysqlpp::sql_varchar b, mysqlpp::sql_int c
>> );
>> ~User();
>> void foo();
>> };
>>
>
> In C++, if a derived class has a function with the same name as one in the
> base class, the derived class's versions always hide those in the base
> class. Thus, your single ctor in the derived class hides these ctors
> defined in the base SSQLS:
>
> User(); // default ctor, needed by STL containers
> User(const mysqlpp::Row& row); // what your error is about
> User(const mysqlpp::sql_varchar& a); // for-comparison ctor
>
> You need to define all of these in your derivative for it to be a true
> SSQLS. Their implementation can be trivial: just call the base class ctors
> of the same signature, passing along the parameters directly.
>
> Technically, the one ctor you do have hides a similar one in the base
> SSQLS: the full-initialization ctor takes its parameters by const reference,
> not by value. You should redefine your one existing ctor like so:
>
> User(const mysqlpp::sql_varchar& a, const mysqlpp::sql_varchar& b, const
> mysqlpp::sql_int& c);
>
> Failing to match this signature won't prevent good code from compiling, but
> taking the parameters by reference is more efficient in the case of
> stringish data types. And if you're going to take them by reference, making
> them const references is simply a matter of correctness, since you aren't
> actually modifying the referents.
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:
> http://lists.mysql.com/plusplus?unsub=loic.dardant@gmail.com
>
>
--
Loïc Dardant
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic