   C++ Basic Organization
  So far I all know (well I think I know) is that the organization levels go from*Librarieswhich are made of*Packageswhich are made of*Classeswhich are made of*Objects and Functionswhich are made of*Primitive DataI'm not even sure what an object is...I'm also wondering how you create/declare and then use each of those items... Kind of a broad topic, but then again I'm kind of confused...Any help or examples (not source code just in layman's terms) would help me immensely.   
  Bluntly, no.There are two types of libraries for C++. The one is called a static import library, which is basically a concatenation of object files. The other is called a dynamic link library (or shared object if you're a Unix guy), which contains executable code.Object files are the result of compiling a single C++ translation unit. Object files contain symbolic object code, which must be linked to for an executable binary (which DLLs/SOs are).A translation unit is a single C++ implementation file (.cpp) and all the headers it includes, and all the headers they include, and so on. This is all substituted in place (the contents of a header file for the corresponding #include file)*, resulting in one large implementation file that is fed to the compiler.An implementation file contains C++ code, which is statements and expressions that declare and define primitive types, functions, classes, objects and so forth. A discussion of each of those terms is technically unrelated to all of the preceding, because the terms already covered deal with organizing and building C++ code files.*When substituting a C++ header file in place, the entire contents of X.h are evaluated by the preprocessor (the program doing the substituting; #include is a preprocessor directive) and the results written to replace the line #include "X.h". There are other preprocessor directives you may recognize, though, most notably #define. If a header contains a symbol definition (#define MAX_ARGS 25), then every instance of the symbol in the text of the header file will be replaced with the specified value. Further, if the header contains a test for that symbol, conditional compilation is effected - you choose how compilation proceeds based on which symbols you've defined.The most common and basic use of this is the "inclusion guard" idiom:#ifndef MY_SYMBOL#define MY_SYMBOL// header code#endifThe effect of this pattern during preprocessing can be illustrated as follows: say main.cpp includes base.h and derived.h, and derived.h also includes base.h. When processing main.cpp, the preprocessor will spot the #include "base.h" directive and will check for the existence of the inclusion guard symbol in base.h (usually something like MY_BASE_H), then create the symbol since it didn't find it. it will then copy the full contents of base.h into main.cpp. The processor then opens up derived.h, whose first statement is a directive to include base.h. The processor opens base.h and checks for the symbol MY_BASE_H, which is defined this time - from the first time we went through base.h, and then skips the whole file until it finds the matching #endif. it then returns to derived.h and processes the rest of that file.Other uses include providing different code to the compiler for different operating systems or external libraries, or even for different compilers:#ifdef _WIN32  // Windows code#else  // Unix code#endifIt is vitally important that you read Organizing Code Files in C and C++, it helps you grasp the practical implications of everything described above.   ;  I assume by packages you mean namespaces, packages are just so Java :PThe library part I think really depends on the kind of application youare building. Most applications will contain namespaces to organisethe different sub-systems but it is optional. All object-oriented C++ applications will contain classes, objects, functions and primitive data.Objects are basically 'instances' of classes. So classes define thekind of object you want to create, and then the object itself would bean individual version of that class, with its own allocated memory andvalues. So you would create a 'npc' class, but you would have a hundredNPC objects (better known as instances).Functions I guess come in two forms, one is due to the backward natureof C++, you can create functions outside classes (which messes up your organisation tree) but those that follow good practices will encapsulate the function into a good well named class. These functionsare actually known as methods, and just to clarify functions are notjust 'void doStuff()' but also overloaded operators (such as + and -!).So to summarise, libraries are just like applications, but they aredesigned to be 'added to' other applications rather than run (andas a result, they are usually linked into your final product ratherthan produce a .exe file). Packages (better known as namespaces) just group classes together, mainly for organisation but also to stopconflicting class names (two classes called 'NPC' but do totally differentthings). Classes come in different flavours (like interfaces and abstractclasses) but ultimately, they describe what an object is. Primitive data is basically the simple data types that make up the code such as integers, floats, doubles. That's the best I can explain it.Edit: To clarify, a library type of 'end product' you want to build. MostC++ developers will never create a library type, they'll just create thestandard application with namespaces, classes, etc and probably use otherpeople's libraries (that was the other guy's goal) to enhance their application (to save time).   ;  C++ has no notion of packages, per se. It now has namespaces, but they are not full-fledged objects with properties like in other language (C++ natively has little to no introspective capabilities - and I make the caveat "little to no" only because of the argument presented by typeid/RTTI). Interestingly, namespaces are pervasive throughout the language: classes/structs, enums and unions are all namespaces of one form or another.Use of classes in C++ is optional. C++ does not compel you to organize your code in any particular way, though there are Best Practices associated with the language. Classes are used to provide a blueprint for objects (which are instances of classes). Since objects tend to work best as aggregations of closely-related data and the functions that operate on them, that's a good rule of thumb for when to create a class: when you have data and a collection of functions to operate on said data, and no reason for ownership of the individual data to be dispersed about your program.Class member functions differ from regular functions in that they take a hidden first parameter called this, which refers to the object (containing the data) that the function is to operate on. That also suggests that it is not a good idea to put functions in classes that do not operate on per-object data. So-called "utility classes" that only serve to collect functions (eg. a Math class) should really be namespaces.Software development is riddled with buzzwords and incredibly prone to fads. Advocates of the technique du jour will attempt to convince you of the necessity of programming according to the doctrine they preach. Your task is to learn when one approach is appropriate, and when to use another. Remember, they're all tools, not religion, so you can mix and match as needed.Happy hacking!   ;Quote:Original post by tariqwaljiFunctions I guess come in two forms, one is due to the backward nature of C++, you can create functions outside classes (which messes up your organisation tree) but those that follow good practices will encapsulate the function into a good well named class.A function that shouldn't be in a class shouldn't be in a class. Not everything belongs in a class.   ;Quote:Original post by OluseyiSoftware development is riddled with buzzwords and incredibly prone to fads. Advocates of the technique du jour will attempt to convince you of the necessity of programming according to the doctrine they preach. Your task is to learn when one approach is appropriate, and when to use another. Remember, they're all tools, not religion, so you can mix and match as needed.Blasphemy!!!Quote:A function that shouldn't be in a class shouldn't be in a class. Not everything belongs in a class.Touche!   