C/Visual C - URGENTE PORFAVOR: Error que no se solucionar

 
Vista:

URGENTE PORFAVOR: Error que no se solucionar

Publicado por david (1 intervención) el 15/12/2008 05:40:16
Buenos dias.
Escribo porquè estoy desesperado con un error en la compilacion que no entiendo de donde procede ni como solucionar-lo, soy estudiante de engenieria informàtica y tengo que presentar esta pracica el miercoles i llevo dos dias buscando por internet como solucionar el problema pero no lo consigo.

El error que me da es el siguiente:

Cjt_Noticies.cpp: In member function ‘void Cjt_Noticies::votar_noticia(int, int)’:
Cjt_Noticies.cpp:8: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript

Aqui dejo el codigo:

****CJT_NOTICIAS.HPP****

#ifndef _CJT_NOTICIES_HPP
#define _CJT_NOTICIES_HPP

#include "Noticia.hpp"
#include "utils.PRAP"
#include <vector>

class Cjt_Noticies
{

private:
vector<Noticia> vnoticies(MAX_NOTICIAS);
// MAX_NOTICIAS es una constante
int cont;

public:
void votar_noticia (int noti, int vots);
void afegir_noticia (int tema, int subbasic);
int consultar_vots_noticia (int noti);
int consultar_tema_noticia (int noti);
int consultar_tema_basic_noticia (int noti);
bool es_pref (int noti);
void canviar_pref_noticia (bool pref, int noti);
void escriure_no_preferents_tema (int tema);

};

#endif


*****CJT_NOTICIAS.CPP******

#include <iostream>
#include "Cjt_Noticies.hpp"
using namespace std;

void Cjt_Noticies::votar_noticia (int noti, int vots)
{
vnoticies[noti].incrementar_vots(vots);
}

void Cjt_Noticies::afegir_noticia (int tema, int subbasic)
{
vnoticies[cont].crear_noticia(tema, subbasic);
}

int Cjt_Noticies::consultar_vots_noticia (int noti)
{
return vnoticies[noti].consultar_vots();
}

int Cjt_Noticies::consultar_tema_noticia (int noti)
{
return vnoticies[noti].consultar_tema();
}

int Cjt_Noticies::consultar_tema_basic_noticia (int noti)
{
return vnoticies[noti].consultar_tema_basic();
}

bool Cjt_Noticies::es_pref (int noti)
{
return vnoticies[noti].consultar_pref();
}

void Cjt_Noticies::canviar_pref_noticia (bool pref, int noti)
{
vnoticies[noti].canviar_pref(pref);
}

void Cjt_Noticies::escriure_no_preferents_tema(int tema)
{
int aux = 1;
while (aux <= cont){
if ((vnoticies[aux].consultar_tema() == tema) and (vnoticies[aux].consultar_pref() == false)) {
cout << aux << " " << vnoticies[aux].consultar_vots() << " " ;
}
++aux;
}
}

_____________________________________________________________________________________________________

Como veis esta parte de codigo es bastante senzilla, pero cada vez que utilizo el vector "vnoticies" me sale este error.

Si alguien pudriera ayudarme de verdad que le estaria muy muy agradecido, porque estoy desesperado. Muchisimas gracias de antemano.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:URGENTE PORFAVOR: Error que no se solucionar

Publicado por Tom (619 intervenciones) el 15/12/2008 11:48:41
En principio, el índice del array debería ser un tipo unsigned ... pero no sé si ese será el error.
Prueba con el método at.

vnoticies.at(noti)->incrementar_vots();
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar