Computer Programming

note /search

C versus C++

  • Politechnika Śląska
  • Computer Programming
Pobrań: 14
Wyświetleń: 840

C versus C++  C++ requires more initial effort than C  For simple tasks, C++ makes no sense  But - by the time you realize a task is not simple, it may already be in C...  A common solution: ...

C++ history

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

C++ history  There was no A language  The BCPL language (1967, now dead)  B: a successor of BCPL (1969)  C: a successor of B (1970)  C++: a superset of C (1983)  Both C and C++ are alive  Author: Bjarne Stroustrup, 1983  Uses C a...

Comments

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

Comments /* C-style comment, valid also in C++, may be several lines long */ // C++ one line comment // ends with End Of Line We may still use the preprocessor to comment out large blocks of source code #if 0 if (i99) { fprintf(stderr,”index out of range\n”); exit(1); } #endif /* use C comments for...

Const and volatile

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

const, volatile  const const int ci =7;  volatile volatile int vi=8; i++; i--; i=i+0;  const and volatile objects  we may call only the const and/or volatile methods for const and/or volatile objects respectively  Warning: declaring const and/or volatile method usually causes overloading of th...

Conversion derived - base

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

Conversion derived - base  The conversion from ”pointer to derived” to ” pointer to base” is allowed and automatic without explicit cast operator  … if inheritance was public - Why only one-wa...

Conversion operator

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

Conversion operator  a.k.a. conversion function / method,  it converts object of its own class to other class T::operator X();  Conversion operator of class T to the X type: - no return value specified, - no argument(s) specified, - declared as a class method  example: person::operator int(); ...

Copy constructor in derived class

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

Copy constructor in derived class  It is a constructor so: - Remember the order of constructors: base class(es) constructor(s) will always run - One may supply parameters for base class constructor at initiation list - Remember: also member objects will be constructed class derived:public base { ....

Copy constructor

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

Copy constructor  Used for initializing objects using other objects of the same class, for the T class: T::T(const T &);  Parameter has to be a reference; otherwise temp. object would be created, that should also be somehow initialized - with the copy constructor!  Parameter should be const ...

Declarations are statements in C++

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

Declarations are statements in C++  declaration inside block is a statement  it may be placed after other statements { int i=12; cout ...