I'm trying to understand the basics of C++ classes and the different forms of copying a class to another one, I made a simple class that use a table as a stack and i created simple function for stacking/unstacking integers pileInt.h :
Код: Выделить всё
class pile_entier{ public: int* p; int n; int counter; public: //Constructeurs & Déstructeurs pile_entier(int n); pile_entier(); ~pile_entier(); //Les Méthodes void empile(int p); int depile(); int pleine(); int vide(); }; Код: Выделить всё
#include #include "pileInt.h" pile_entier::pile_entier(int l){ n=l; p=new int [n]; counter=0; } pile_entier::pile_entier(){ n=20; p=new int [n]; counter=0; } pile_entier::~pile_entier(){ delete[] p; } int pile_entier::pleine(){ return counter ==n; } int pile_entier::vide(){ return counter==0; } void pile_entier::empile(int i){ if(pleine()){ std::cerr
Источник: [url]https://stackoverflow.com/questions/78132207/problems-related-to-shallow-copy-in-c[/url]
Мобильная версия