#pragma once #ifndef _Steak_H_ #include"Node.h" #include<cstdlib> #include<iostream> #include<iomanip> using namespace std; #define _Steak_H_ class Stack { Node *hight_stack_ptr;// Верхушка стэка public: Stack(const Stack &obg);//Конструктор копирования Node *get_hight_steak_ptr(); } ---------------- //cpp file #include "Stack.h" Stack::Stack() { hight_stack_ptr = nullptr; } Stack::Stack(const Stack &obg) { hight_stack_ptr = nullptr; Node ptr = obg.get_hight_steak_ptr();//Почему нельзя вызвать метод get??? }
|
1 answer
Well, you cannot call it, because the method is declared as non-constant, so for a constant obj
it cannot be called ...
Declare it as
Node *get_hight_steak_ptr() const;
That's what you want to get - in the sense of your
How to get the address of the stack stack
Why do you think that this method gives you a "top of the stack"? ... something, in my opinion, you are not so in the very title of the question ...
|