Answer the question
In order to leave comments, you need to log in
How to get a reference to a structure in a class?
Task: in getfirst() return a reference to the structure pointed to by first or the value of first. Trying to do this causes a problem.
Issue: Syntax error (probably in function definition header). I tried all conceivable options (I think it's pointless to list them?)
I cut off everything superfluous in the program so that the problem area was immediately visible.
Help a student, please.
template <class T>
class storage
{
struct storagestruct
{
T item;
storagestruct* next = nullptr;
};
private:
storagestruct* first = nullptr;
public:
storage<T>() {};
virtual ~storage();
storagestruct& getfirst();
};
template<class T>
storage<T>::storagestruct& storage<T>::getfirst()
{
return *first;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question