Well, I'm trying to implement the copy_and_swap idiom on my first Stack in C++, for that I need to create a swap function and this swap function needs to be a friend function, I tried to do it by this way:
template <class T>
class Stack {
private:
int top;
T* a;
int MAX;
public:
Stack(int MAX);
Stack(Stack<T>& s);
bool push(T x);
bool pop();
T peek();
bool isEmpty();
friend void swap(Stack<T>& f, Stack<T>& s);
~Stack();
};
template <class T>
void Stack<T>::swap(Stack<T>& f, Stack<T>& s){
//I will put something where yet.
}
But, the VSCode says this about the swap function: class model "Stack " does not have a "swap" member (I translate for English, my VSCode runs in Portuguese).
How I can do that without receiving this error?