Politechnika Śląska - strona 310

Structures and classes

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Computer Programming
Pobrań: 0
Wyświetleń: 490

Structures and classes  Initialization in braces { } is valid only for classes: - whose all fields are public - that have no explicit constructor struct s_xy { int x, y; }; s_xy sxy={10,20}; // ok //s_xy sxy1(10,10) - bad! struct xy { int x,y; x...

The default constructor

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Computer Programming
Pobrań: 0
Wyświetleń: 441

The default constructor  If no constructors were declared, the compiler generates a default constructor  It is a constructor with no arguments, of an empty body, for the T class: T::T() { }  If we declare any constructor (even constructor with args) then compiler does not generate the default co...

This

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Computer Programming
Pobrań: 0
Wyświetleń: 518

This  exists in every non-static method  a pointer to the object, for which the method was called  used for returning reference or pointer to the object for which the method was called  does not occupy

Type void

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Computer Programming
Pobrań: 0
Wyświetleń: 546

Type void *  no automatic conversion to other pointer types void *malloc(size_t size); char *str; int *pi; str = (char *) malloc(10); pi = (int *)malloc(100);  automatic conversion from almost any pointer type (exception: const *, volatile *) vo...

Unions

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Computer Programming
Pobrań: 0
Wyświetleń: 518

Unions  In C++ a union is a class, but: - It cannot contain objects with constructors or destructors defined - There can be no access restrictions - all the fields are public - It cannot inherit from a class ...

Why to inherit

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Computer Programming
Pobrań: 0
Wyświetleń: 490

Why to inherit? class person { char * name, * surname; public: void print_name (); void print_surname(); void print_all(); } class adult { char * name, * surname, * ID_card; public: void print_name(); void print_surname(); void print_ID_card(); void print_all(); } class person { char * name, * surn...

Why to use OOP

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Computer Programming
Pobrań: 0
Wyświetleń: 525

Why to use OOP  next stage in the software engineering evolution: - structural - procedural - modular  tool for implementing OO projects (there is OO analysis, OO design)  languages that sup...

Assert

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 455

 void assert(int expression ); - Macro used to add diagnostics. - If expression is false, message printed on stderr and abort called to terminate execution. Source file and line number in messag...

Basics of graphics

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 413

Graphics - basics  Vectors  image described as a set of basic shapes (lines, circles etc.)  accurate description  easy transformation  limited application  Bitmaps  image described as a matrix of pixels  limited resolution  needs much more mem...

Bitmaps

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 490

Bitmaps  Most commonly used today  Memory requirements for a standard screen: - 1280*1024*3 bytes = 3 932 160 bytes  Processing speed for real-time display: - we need about 15 fps - ...it means: 59 millions of bytes per second - ...and today...