Here's a minimal program that also makes the same error message, in case it's still confusing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Example program
struct Foo {
int bar;
};
Foo func()
{
return Foo(); // returning a temporary value
}
int main()
{
func().bar += 3; // trying to increment a temporary value.
}
13:16: error: using temporary as lvalue [-fpermissive]
Aside from the fact that you're not returning references, another issue with these functions is that not all control branches return a value.
Nothing is returned if last == NULL... And you can't have null references by design in C++. There's no perfect solution to this. You could throw an exception. The standard library's containers will just create undefined behavior if you try to access an empty container's back() or front().
Exception safety
If the container is not empty, the function never throws exceptions (no-throw guarantee).
Otherwise, it causes undefined behavior.
Edit:
1 2 3 4 5 6 7 8 9 10
struct polinom
{
int koef;
int stepen;
}c;
struct polinom1
{
int koef;
int stepen;
}o;
Please note there that you're creating global objects for polinom and polinom1, which you don't even use, and also these are shadowed by the inputs to your functions (like queue::push).
In general, you should avoid using global variables. And use DESCRIPTIVE variable names. "o" and "c" are not good variable names. Also, the difference between "polinom" and "polinom1" is non-existent as far as the data goes, why do you have two structs?