Goto
- Politechnika Śląska
- Computer Programming
Goto more restrictions than in C: - cannot jump over initialization (in C initializations are always before goto-s…) - … this function is wrong: void fn(void) { goto end; int i = 1; end: ; } ...
Ta witryna wykorzystuje pliki cookie, dowiedz się więcej.
Goto more restrictions than in C: - cannot jump over initialization (in C initializations are always before goto-s…) - … this function is wrong: void fn(void) { goto end; int i = 1; end: ; } ...
Hermetization and encapsulation encapsulation - defining all data and methods in single class hermetization - restricting access to class members All class members are private by default OOOP — orthodox OOP: - all class data members are private - we access them from outside through class method...
Inheritance Reveals hierarchic relations between classes To develop (extend) existing classes without need to modify or recompile them Reusability of code (one defines only what is added or changed, all the rest is reused) Base class p...
Inline functions inline int sum(int a, int b) { return a+b; } places the code in place where it is called many copies in case of many calls destined to replace macro definitions inline keyword is only a recommendation for the compiler au...
Many objects Usually many objects are similar - with the same set of features We define the set only once and use it many times class — a group of items, things etc., possessing some features in common We need one class for all similar objects ...
Member access operator - T* operator-(); T t; t-m is interpreted as: ( t.operator- )-m we may use object as if it were a pointer if operator- returns no pointer, then - we still may use it: a=t.operator-(); - we cannot do: a=t-; it's a syn...
Object Common understanding of ”object” ” Object” in programming - represents real-life or abstract objects - is a generalized variable (structure) - is a being defined and used according to syntactic and semantic rules of the programming language Structure - set of data elements, usually of ...
Operators for accessing class members dot ” . ” object.variable; // just like in a C structure object.method(); // encapsulation scope operator ” :: ” class::variable; // sizeof, static variables class::method(); // defining methods, static methods Scope definition (object. and class::) usual...
Prototypes of fun ctions Function prototypes are required!!! (return value, name, arguments) In C: a prototype int f() is assumed, in C++ not #include ”foo_prototypes.h” void foo(); … foo(); … void foo() {}; ...
References reference to type T: T& it is a pointer that looks like a variable int i=7, // variable int & iref=i; // reference must be initialized // i.e. associated with something (i) iref++; // now i==8 may be misleading avoid funct...