Metoda zwracająca adres do obiektu

0
class Cell_list
{
public:
	Cell_list * next = nullptr;
	int variable;
};

class Linked_list
{
public:
	Cell_list * head = nullptr; // or first
	void printl();
	size_t list_size();  // zliczamy ilość wlementów listy
	Cell_list *address(size_t i);
	void push_front_cell(int variable);
	void pop_front_cell();
	void push_back_cell(int variable);
	void pop_back_cell();
	void insert_before_cell(int variable, size_t i);
};

Cell_list *Linked_list::address(size_t i)
{
	Cell_list *temp = head;
	size_t j = 0;
	while (temp)
	{
		if (i == j++) return temp;
		temp = temp->next;
	}
	cout << "NIE UDALO SIE ZNALEZC PODANNEGO ADRESU" << endl;
}

void Linked_list::insert_before_cell(int variable, size_t i)
{
	Cell_list *temp = head;
	if (**temp == address**) push_front_cell(variable);  // wywal ami tu błąd
	//.....
	//.....
	//.....
}

zrzut.png

3

a niby czym jest ten symbol address?
Zmienna?
Pewnie chciałeś podać argument if (temp == address(i)).

0

nie było pytania ;D

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