List:MySQL++« Previous MessageNext Message »
From:Loïc Dardant Date:July 2 2008 1:03pm
Subject:Re: Derive a structure and use it with storein
View as plain text  
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@stripped>:

> 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=1
>
>


-- 
Loïc Dardant

Thread
Derive a structure and use it with storeinLoïc Dardant2 Jul
  • Re: Derive a structure and use it with storeinWarren Young2 Jul
    • Re: Derive a structure and use it with storeinLoïc Dardant2 Jul