expected primary-expression before ‘unsigned’

Greetings, I'm new to C++ programming and have been studying it for a couple of days. I have run into a few problems, like all beginners, but have always been able to figure them out until now.The program I am stuck on is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
unsigned int mapeo( lista<unsigned int*> lst,
			unsigned int size, unsigned int addr) {
  lst.ultimo(); 
    return (addr + (size * sumatoria(lst))); 
}

  unsigned int sumatoria( lista<unsigned int*> lista) {
  unsigned int *tmpvect; 
  unsigned int resultado; 
  tmpvect = lista.getNodo(); 
  lista.anterior(); 
  if (!(lst.esPrimero())){
    resultado += ( ( (*(tmpvect + 2)) - (*(tmpvect + 0))) + 
		   ( (*(tmpvect+1)) - (*tmpvect) + 1)        
		   * sumatoria(lista) );                     

    return resultado;
  }
  else
    return (*(tmpvect + 2)) - (*(tmpvect + 0)); 
                                                
}


and one of the errors i get is the "Exprected unqualified-id before 'unsigned'

main.cc:24:27: error: expected primary-expression before ‘unsigned’


i copied this code from a booklet i found and i'm guessing there could be something wrong with my compiler because i copied it exactly the same.

The code is supposed to map the address from a list with the parameters of a N-dimensional array pointing to a particular subindex.

could someone assist me on solving this error please?
I found that GCC prints a similar error, although it is on lines 1, 2, and 7, not 24, of the code you posted. Please post the same code you're compiling next time!

And that is not the first error message printed; the first one is
test.cc:1:21: error: ‘lista’ was not declared in this scope

If you fix it, then the message "expected primary-expression before ‘unsigned’" will disappear as well.
It should belist not lista
this is the code i'm compiling!

i had the terminal so small that i didn't realize there was another error line before the one i posted.
I really appreciate your help and your rapid response.

Could you give me a hint on how to declare 'lista' ?

i'm not really a very skilled programmer and i'm not really used to this language neither hehe
is lista a class object? or is it supposed to be list? Also line 7 you should not name the "object" the same as the "variable name" that is like doing int int.
Last edited on
lista is a class object
you declare lista like
1
2
lista lst;
lst.something();


You were trying to use lista as a vector of int pointers.
like this
 
std::vector<unsigned int*> vec;


*edit
You can also make a vector of objects like
 
std::vector<Lista> vec(SIZE);
Last edited on
Topic archived. No new replies allowed.