C++.. PART4

Ok … so let’s go further becasue it seems that this was a quite long-time approach. Anyway I don’t want to wander into useless details but on the other hand I don’t want to miss something that could be important.

18. Class vs Struct – this will be just a discussion about C structs and C++ classes, so emphasizing the main aspects of object oriented programming.
C structures are the part of C language which makes the transition to C++ and object oriented programming. In C they were designed to be more some data
containers, that’s why in C structs you cannot add functions (if it is to take into consideration differences between C++ structs and C++ classes only
the default access type will be considered: public for struct, private for class). When defined a C++ class does not take memory storage, it happens
only when it is instantiated.

But how things are really passing concerning classes’ declaration, definition and instantiation? Basically classes’ definitions are kept in header files and their
declarations and instantiations in source files, in other words everything that does not have an active role in programs’ execution is kept in headers and the program itself, the part that is indeed executed is kept in .c files. This is not mandatory, this is not requested by the standard, but is just a guideline.

Also a frequent practice in designing classes is to declare its members as private and corresponding functions, which access them as public. Actually
this is the very nature of encapsulation, classes’ characteristics are not visible outside of the class but can be modified from within by some functions
which are accessible from outside.

Go on further to #19

Advertisements

Brief guide to Symbian C++

… actually you can find this information on a dozen of other sources, but if you bothered (if this is so I will thank you) to click on my blog, it worth reading it.

Maybe the difference in between what is written here and on some other web resource, is that those things out here are  coming from a Symbian newbie, so …

Symbian developers from all over the world (I am addressing here to the beginners among you)  unissez vous !

Do you already have a C++ background and do you want to start learning about the worlds’ most deployed mobile operating system ? If you happily answer YES to both questions, you may need informations out here.

Many Symbian C++ books assume that you are already familiar with C++ but not that you have an in-depth knowledge of the operating system, actually many of them include some statements like this one:

If you are a developer targeting, or thinking of targeting, Symbian OS, this book will show you how to write the most effective C++. You will benefit from a greater understanding of the characteristic features and design of the operating system, and confidence in how to use them.

the author warns:

We encourage you to follow them too, in order for your own code to be understood most easily by other Symbian OS developers, and because the conventions have been chosen carefully to reflect object cleanup and ownership, and make code more comprehensible. An additional benefit to using the conventions is that your code can then be tested with automatic code analysis tools, which can flag potential bugs or areas to review.

… just taken from Symbian OS explained by Jo Stichbury, a Symbian OS and Symbian C++ golden reference

The general picture being drawn I will procede with Symbian C++ code conventions.

  1. Capitalization – each class name must be capitalized, rest of the letters must be in lower-case.
  2. CClass Instance1; //this is OK
    CCLASS Instance2; //this is NOT OK Go on further