Would anyone know a way of explaining or could you direct me to some material regarding wrapper classes? I don't understand them at all. Every explanation I read is in very complicated English.
I want to understand them completely. Either a really good article / book / website etc where this is explained well would be well appreciated.
I'm hoping to find something for wrapping a C Class with C++ (if that makes sense).
Thanks for coming back. I'll look at those points.
I eventually want to build a desktop database using SQLite. SQLite source code is written in C though the application I am going to build will be in C++. In order to be able to commuinicate with a C RDBMS (possibly also to compile and integrate this RDBMS) into a C++ app I believe I need to write wrapper classes for the C++ code to interface with the C code.
I know my explanation shows a lack of experience on the topic though I have years to work on this and believe that by understanding this wrapper concept properly I'll be able to write a wrapper class or several for the purpose of building this application.
C++ can call C functions without any translation. You do not need a wrapper class to use SQLite. All the C examples will work directly in C++.
One reason you might want to wrap it is if you want something to manage handles associated with SQLite and provide type-safe use. Typically a C interface will have a "pointer to anything" with a "tag" indicating the actual type involved. It then becomes the programmer's responsibility to ensure the correct type is used. A type-safe wrapper would allow the compiler to confirm the correct types are being used at compile time, or the wrapper to do the check for you at runtime.
Wrapping to control access to a resource should not be needed.
The main point of a database engine is that is provides atomicity of operation for you. You should not need to lock the db yourself, just issue commands through its interface. When you do a transaction the underlying database is not changed until you 'commit' the transaction at which point the changes occur atomicaly.
Wrapping to provide type safety is important.
Integer ids are often used in relational databases as a table sequence number. You might have integers 'customer_id', 'product_id' etc. You could store these in a plain int - but don't!
When you are deep in your code you might lose track of whether the int you have is one or the other of these. Wrap them in simple classes to provide type safety.