Stos obiektowo – kilka błędów kompilacji

0

Witam, ćwiczę obiektowe programowanie. na razie jestem na poziomie zerowym, ale mam takie problemy.

#include <iostream>
#include <cstdlib>

using namespace std;

class stos{
    private:
    int *tab;
    public:
    stos(){}
    stos(int t){
        this->tab=new int(t);
    }

};

int main()
{
    stos tro=new stos(6);
    return 0;
}

wywala kompilator takie błędy:

error: invalid conversion from 'stos*' to 'int' [-fpermissive]
note: initializing argument 1 of 'stos::stos(int)'

co jest nie tak?

3

Zapomniałeś o gwiazdce

stos * tro = new stos(6);
3

jak dajesz new, to musisz zwolnić potem pamięć!!! To nie jest JAVA!

1 użytkowników online, w tym zalogowanych: 0, gości: 1