- Help on conversion to a reference in a derived object - 1 Update
- SQL filesortcc question - 2 Updates
- What practice can get speed improvement in C++? - 1 Update
fl <rxjwg98@gmail.com>: Jul 16 02:31PM -0700 Hi, I have difficulties when reading book "C++ Primer" on derived class section. In chapter 15, on OOP, it has a section titled "Conversion to a Reference is Not the Same as Converting an Object". "As we've seen, we can pass an object of derived type to a function expecting a reference to base. We might therefore think that the object is converted. However, that is not what happens. When we pass an object to a function expecting a reference, the reference is bound directly to that object. Although it appears that we are passing an object, the argument is actually a reference to that object. The object itself is not copied and the conversion doesn't change the derived-type object in any way. It remains a derived-type object". First of all, I am not sure about whether there is a conversion to a reference or not from the above. (There is a reference conversion, though not change the derived-type object in any way? This sentence is puzzling me a lot.) Then, the following section "Using a Derived Object to Initialize or Assign a Base Object" has: ... "Because there is a conversion from reference to derived to reference to base, these copy-control members can be used to initialize or assign a base object from a derived object:" This paragraph clearly said there is a reference conversion from derived to the base. Could you make it clear to me? Thanks, |
doctor@doctor.nl2k.ab.ca (The Doctor): Jul 16 08:15PM >Yeah, it is only 12 years old. :-) >Bo Persson It still works. Anyone for GCC 2.95 ? All right next hurdle: Script started on Thu Jul 16 13:58:08 2015 doctor.nl2k.ab.ca//usr/source/mysql-5.6.25$ gmake [ 0%] Built target INFO_BIN [ 0%] Built target INFO_SRC [ 3%] Built target strings [ 10%] Built target mysys [ 10%] Built target dbug [ 10%] Built target mysys_ssl [ 10%] Built target comp_err [ 10%] Built target GenError [ 10%] Built target blackhole [ 10%] Built target blackhole_embedded [ 10%] Built target archive [ 10%] Built target archive_embedded [ 10%] Built target federated [ 10%] Built target federated_embedded [ 12%] Built target myisammrg [ 14%] Built target myisammrg_embedded [ 15%] Built target slave [ 15%] Built target gen_lex_hash [ 15%] Built target GenServerSource [ 15%] Built target gen_lex_token [ 15%] Built target GenDigestServerSource [ 21%] Built target perfschema [ 26%] Built target myisam [ 26%] Built target csv [ 29%] Built target heap [ 38%] Built target innobase [ 39%] Built target regex [ 40%] Built target vio [35m [1mScanning dependencies of target sql [0m[ 40%] [32mBuilding CXX object sql/CMakeFiles/sql.dir/sql_partition_admin.cc.o [0m [31m [1mLinking CXX static library libsql.a [0m[ 52%] Built target sql [ 54%] Built target binlog [ 55%] Built target rpl [ 55%] Built target master [31m [1mLinking CXX executable mysqld [0mlibsql.a(handler.cc.o): In function `get_ha_partition(partition_info*)': /usr/source/mysql-5.6.25/sql/sql_alloc.h:30: undefined reference to `ha_partition::ha_partition(handlerton*, partition_info*)' libsql.a(handler.cc.o): In function `get_ha_partition(partition_info*)': /usr/source/mysql-5.6.25/sql/mysqld.h:765: undefined reference to `ha_partition::initialize_partition(st_mem_root*)' libsql.a(sql_partition_admin.cc.o): In function `Sql_cmd_alter_table_truncate_partition::execute(THD*)': /usr/source/mysql-5.6.25/sql/sql_partition_admin.cc:822: undefined reference to `ha_partition::truncate_partition(Alter_info*, bool*)' gmake[2]: *** [sql/mysqld] Error 1 gmake[1]: *** [sql/CMakeFiles/mysqld.dir/all] Error 2 gmake: *** [all] Error 2 You have new mail in /var/mail/doctor doctor.nl2k.ab.ca//usr/source/mysql-5.6.25$ egrep exit exit Script done on Thu Jul 16 14:05:58 2015 so sql/sql_alloc.h <SNIP> /** MySQL standard memory allocator class. You have to inherit the class in order to use it. */ class Sql_alloc { public: static void *operator new(size_t size) throw () { return sql_alloc(size); } static void *operator new[](size_t size) throw () { return sql_alloc(size); } static void *operator new[](size_t size, MEM_ROOT *mem_root) throw () { return alloc_root(mem_root, size); } static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return alloc_root(mem_root, size); } static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) { /* never called */ } static void operator delete[](void *ptr, MEM_ROOT *mem_root) { /* never called */ } static void operator delete[](void *ptr, size_t size) { TRASH(ptr, size); } #ifdef HAVE_purify bool dummy; inline Sql_alloc() :dummy(0) {} inline ~Sql_alloc() {} #else inline Sql_alloc() {} inline ~Sql_alloc() {}
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment