Computer Programming - strona 4

note /search

Function call operator

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 525

Function call operator result T::operator()(args);  Any number of arguments, overloadable  Exception: function call operator may have default arguments  We may use an object as if it were a function T ob; ob();  we use it - when there is no appropriate operator, that we needed - there is a domi...

Order of constructor calling

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 462

Order of constructor calling  Constructors 1. base class (classes in order of declaration) 2. class members in order of declaration 3. constructor's body  Object class members (and base classes), if not initialized in the initialization list, are actually initialized twice: 1. by the default cons...

Types

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 602

Types  stronger type control (compared to C) - to permit error detection by the compiler  automatic type conversions - when it does not lead to ambiguity  whenever it is possible, no precision or information is lost; not guaranteed for all conversions: char/short/int/long/single/float/double/sig...

Why to learn C++

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 448

Why to learn C++  More scalable than C - project size - number of programmers  Reuse code written by you and others - many libraries available  Many tools and other languages are based on C++  It has become a standard ...

Associativity

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 637

Associativity  assignment and unary operators are of right associativity a=b=c is equivalent to a=(b=c)  remaining ones are of left associativity a+b+c is equivalent to (a+b)+c ...

Class in programming

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 448

Class in programming  Class in programming — generalized type defined by the programmer  used for defining objects (generalized variables)  provides programmer with new possibilities  a class should clearly represent specific concept, idea, or real-life being, that has not been yet described by...

Class members access rules

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 483

Class members access rules  private: private members accessible for methods of this class, for methods and functions declared as friends In a class, all members are private by default  public: public members accessible from outside the class In a struct, all members are public by default  protec...

Classes and Abstract Data Types

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 329

Classes and Abstract Data Types  classes are suitable for implementing Abstract Data Types  classes are Abstract Data Types  We define an interface - we do not care how the methods are implemented - details are separated from the class interface (hermetization)  Examples - stack, queue, point, ...

Const and pointers

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 504

const and pointers  pointer to const: const char *pc=”asdf” (or: char const *pc=”asdf”)  const pointer: char * const cp=”asdcf”;  const pointer to const: const char * const cpc=”asdcf”;  mistakes: pc[1]='2'; cp++; cpc[1]='b'; cpc--;  it is co...

Const

  • Politechnika Śląska
  • Computer Programming
Pobrań: 0
Wyświetleń: 546

Const  named constants - replace #defined C constants const five = 5; void foo(const int con_i);  consts - regular variables, with address, size, operators, but not to be modified  const prevents programmer from mistakes  use of consts permits optimization by a compiler ...