Computer Programming - strona 7

note /search

Why to use OOP

  • Politechnika Śląska
  • 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...

A structural example _ person

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

A structural example - person struct person { int age; char FName[20], LName[30]; }; void person_input(person *o); void person_set(person *o, int age, char *pFN, char *pLN); void person_output(person *o);  no access control over data members  the programmer is responsible for using proper functio...

An OO example _ person

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

An OO example - person class person { int age; // class members - class variables char FName[20], LName[30]; public: void input(); // class members - class methods void set(int age, char *pFN, char *pLN); void output(); }; // declaration ends with „ ; ”  data and methods together  default for cla...

Calling a constructor

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

Calling a constructor  Constructor with no args (default constructor): point p1;  Others: point p3(10.0, 20.0); // 2 arg. point p2(1.0); // 1 arg. // point p1(); // this would be a call of p1 function point p2=1.0; // this way 1 arg. con. on...

Constructor _ not a normal method

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

Constructor - not a normal method  We don't specify the returned value (even void)  We cannot call it for an already constructed object  We cannot get it's address  It is not even visible in the class scope and has no name ...

Constructor and destructor for derived class

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

Constructor and destructor for d erived class  Cconstructors are not inherited, but:  Order of constructor calls: 1. virtual base classes 2. non-virtual base classes 3. member objects 4. the class constructor  Destructorss - reverse order ...

Constructor declaration

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

Constructor declaration  For the T class: T(args); or T::T(args); class point { double x, y; public: // … point(double, double); // no return value, even void! point(double); // overloadable point(); }; ...

Constructor - When to define it

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

Constructor  Constructor - method used for initializing objects of a given class - an algorithm for creating object of a given class  When to define it - if class variables need initialization - if something should be done when a new object ...

Default assignment operator

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

Default assignment operator  if we do not define an assignment operator, then the compiler generates one, that simply copies objects field by field - it does not work for const fields - it does not work for reference fields - it simply copies pointer...

Operators as functions

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

Operators as functions  at least one argumen t of the operator should be an object  all the arguments are operator function parameters  there is no this  declaring int operator...