Functii Membre Statice

  • Uploaded by: Patrick Johnston
  • 0
  • 0
  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Functii Membre Statice as PDF for free.

More details

  • Words: 136
  • Pages: 2
Functii membre statice RESTRICTII: 1. au acces doar la alti membri statici ai clasei si la functiile si datele globale 2. nu au un pointer this ACCES: 1. este permis independent de vreun obiect utilizand numele clasei si operatorul de specificare a domeniului 2. este permis in legatura cu un obiect #include using namespace std; class C { static int static_a; int b; public: static int modify_static_a(int i) { return static_a = i; // b = 2; error C2597: illegal reference to data member 'C::b' in a static member function } void arata() { cout<<static_a<<endl; }

}; int C::static_a = 1; //defineste pe static_a void main() { C ob1; C::modify_static_a(2); /* functia membru static poate fi apelata independent de vreun obiect */ ob1.arata(); ob1.modify_static_a(3); /* functia este apelata in legatura cu un obiect */ ob1.arata(); }

Related Documents

Functii Membre Statice
July 2020 10
Fiche Membre
May 2020 18
Functii Trigonometrice
April 2020 13
Membre Ass. Qua.
June 2020 4
Proiect Functii 8.docx
November 2019 8

More Documents from ""