c++ adında bir üyesi yoktur

Bir sorunum var. Dinamik yığın ile program oluşturdum ve derlediğimde hata alıyorum: 'class stos' has no member named 'push' , 'class stos' has no member named 'pop' , 'class stos' has no member named 'destroy' , 'class stos' has no member named 'isempty'. C dilinde program iyi, ancak C++'da değil. C++ ile macerama başladım ve neyi yanlış yaptığım hakkında bir fikrim yok. Bana yardım edebilir misiniz? Bir kod yazıyorum:

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <iostream>
#include <conio.h>

using namespace std;

class stos
{
public:
int *tab;
int licznik;
int rozmiar;

};

void init (class stos* s)
{
s->licznik = 0;
s->rozmiar = 3;
//s->tab = (int*) malloc ( 2 * sizeof * s->tab );
s->tab = (int*) malloc ( s->rozmiar * sizeof(int) );
if (s->tab == NULL)
    {
    cout << "Blad alokacji pamieci\n";
    abort ();
    }
}

void push (class stos* s, int element) 
{
if (s->licznik != s->rozmiar)
    {
    cout << "Dodaj element do stosu\n";
    cin >> element;
    s->tab[s->licznik] = element;
    s->licznik++;
    }
else
{
    s->rozmiar = 2 * (s->rozmiar);
    s->tab = (int*) realloc (s->tab, (s->rozmiar) * sizeof (int));
    cout << "Zwiekszono pamiec\n";
    cout <<"Dodaj element do stosu\n";
    cin >> element;
    s->tab[s->licznik] = element;
    s->licznik++;
}
//system ("clear");
}

int pop (class stos* s) 
{
if (s->licznik == 0)
{
    cout << "Nie podales zadnego elementu\n";
    abort ();
}
else
{
    s->licznik--;
}
return s->tab[s->licznik];
}

void destroy (class stos* s)
{

  free (s->tab);

}

bool isempty (class stos* s)
{   
bool empty = true;

if (s->licznik == 0)
    {
  empty = true;
  cout << "Stos nie posiada zadnych elementow\n";
    }
else
    {
  empty = false;
  cout << "Stos zawiera jakies elementy\n";
    }
return empty;
}

int main () 
{
int element = 0, a = 0;
 stos stos1;
 stos stos2;

    do
    {
    cout << "\nMENU\n\n";
    cout << "STOS I\nAby dodac element do stosu wcisnij '1'\nAby odjac element ze stosu wcisnij '2'\n";
    cout << "Wcisnij '3' aby usunac stos\nWcisnij '4' aby sprawdzic czy stos zawiera elementy\n\n";
    cout << "STOS II\nAby dodac element do stosu wcisnij '5'\nAby odjac element ze stosu wcisnij '6'\n";
    cout << "Wcisnij '7' aby usunac stos\nWcisnij '8' aby sprawdzic czy stos zawiera elementy\n\n";
    cout << "Wcisnij '0' aby zakonczyc dzialanie programu\n\n";
    cin >> a;
    //system ("clear");

    if (a == 1)
    {
        stos1.push (element); 
    }
    if (a == 2)
    {
        cout << "Usunieto element:" << stos1.pop;

    }
    /*if (a == 3)
    {
        destroy (&stos1);
        printf ("Wyczyszczono stos 1\n");
    }*/
    if (a == 4)
    {
        stos1.isempty;
    }
    if (a == 5)
    {
        stos2.push (element);
    }
    if (a == 6)
    {
        cout << "Usunieto element: " << stos2.pop;

    }
    /*if (a == 7)
    {
        destroy (&stos2);
        printf("Wyczyszczono stos 2\n");
    }*/

    if (a == 8)
    {
        stos2.isempty;
    }
}
while (a!=0);
    destroy (&stos1);
    destroy (&stos2);
getch();
return 0;
}

Sorun şu ki "class stos'un push" adında bir üyesi yok. pushvepop` üye olmayan fonksiyonlardır. Görünüşe göre şöyle bir şeye ihtiyacınız var

push (&stos, element); 

ve

pop(&stos1);
Yorumlar (0)

Eğer üye fonksiyonlara sahip olmak istiyorsanız, bunları yazmanız gerekir, örneğin push şu şekilde yazılabilir


class stos
{
public:
void push (int element);
int *tab;
int licznik;
int rozmiar;

};

void stos::push (int element) 
{
if (licznik != rozmiar)
    {
    cout > element;
    tab[licznik] = element;
    licznik++;
    }
else
{
    rozmiar = 2 * (rozmiar);
    tab = (int*) realloc (tab, (rozmiar) * sizeof (int));
    cout 
Yorumlar (0)

Çağırmaya çalıştığınız işlevler stos sınıfında değil Şöyle bir şey yapabilirsin:


class stos
{
public:
int *tab;
int licznik;
int rozmiar;

void init ();
void push (int element);
int pop ();
void destroy ();
bool isempty ()

};

void stos:: init ()
{
this->licznik = 0;
this->rozmiar = 3;
//this->tab = (int*) malloc ( 2 * sizeof * this->tab );
this->tab = (int*) malloc ( this->rozmiar * sizeof(int) );
if (this->tab == NULL)
    {
    cout licznik != this->rozmiar)
    {
    cout > element;
    this->tab[this->licznik] = element;
    this->licznik++;
    }
else
{
    this->rozmiar = 2 * (this->rozmiar);
    this->tab = (int*) realloc (this->tab, (this->rozmiar) * sizeof (int));
    cout tab[this->licznik] = element;
    this->licznik++;
}
//system ("clear");
}

int stos:: pop () 
{
if (this->licznik == 0)
{
    cout licznik--;
}
return this->tab[this->licznik];
}

void stos:: destroy ()
{

  free (this->tab);

}

bool stos:: isempty ()
{   
bool empty = true;

if (this->licznik == 0)
    {
  empty = true;
  cout 
Yorumlar (1)