Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 06-03-2009
torrescrack9 torrescrack9 is offline
Registrado
 
Registrado: feb 2009
Posts: 5
Poder: 0
torrescrack9 Va por buen camino
duda juego c++ builder 2007

Estoy haciendo el juego de simon dice en c++ builder 2007 y tengo la siguiente duda debo dimensionar un vector y he probado de un monton de formas y no soi capaz me da un error....

Mira pongo el codigo aver si alguien sabe a q se debe el error...

Lo que kiero es dimensionar las variables vector y vectorentrada

El error que me sale es el siguiente:

Cita:
---structure required on left side of. or .

--- invalid direction
Código:
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
int repeticiones;
int contador;
short vector;
short vectorentrada;
int i;
const short limiteinf=1;
const short limitesup=4;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
void colores_iniciales()
 {
  Form2->I_1->Picture=Form2->I_gris1->Picture;
  Form2->I_2->Picture=Form2->I_gris2->Picture;
  Form2->I_3->Picture=Form2->I_gris3->Picture;
  Form2->I_4->Picture=Form2->I_gris4->Picture;
 }
void aleatorio(short limiteinf,short limitesup)
 {
  short aleatorio=0;
  Randomize();
  aleatorio=Int((limitesup-limiteinf+1)*Random()+limiteinf);
 }
void inicio()
{
 //int i;
 vector.redim(repeticiones);
 vectorentrada.redim(repeticiones);
 for(i=1;i<repeticiones;i++)
 {
  vector[i] = aleatorio(limiteinf,limitesup);
 }
 Form2->I_1->Enabled=false;
 Form2->I_2->Enabled=false;
 Form2->I_3->Enabled=false;
 Form2->I_4->Enabled=false;
 Form2->Juego1->Enabled=false;
 Form2->Acerca1->Enabled=false;
 Form2->Secuenciador->Enabled=true;
 contador=1;
}
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
 : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormShow(TObject *Sender)
{
colores_iniciales();
repeticiones=1;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Nuevo1Click(TObject *Sender)
{
inicio();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::SecuenciadorTimer(TObject *Sender)
{
colores_iniciales();
if(contador<=repeticiones)
 {
  L_Contador->Caption=contador;
  switch((vector[contador]))
   {
    case 1:
      I_1->Picture=I_rojo->Picture;
      break;
    case 2:
      I_2->Picture=I_azul->Picture;
      break;
    case 3:
      I_3->Picture=I_Amarillo->Picture;
      break;
    case 4:
      I_4->Picture=I_Verde->Picture;
      break;
   }   // fin switch;
   contador=contador+1;
  }
else  {
   L_Contador->Caption="";
   contador=1;
   Secuenciador->Enabled=false;
   I_1->Enabled=true;
   I_2->Enabled=true;
   I_3->Enabled=true;
   I_4->Enabled=true;
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm2::BorradorTimer(TObject *Sender)
{
colores_iniciales();
Borrador->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Salir1Click(TObject *Sender)
{
Form2->Close();
}
//---------------------------------------------------------------------------

Última edición por dec fecha: 06-03-2009 a las 14:55:39. Razón: Poner las etiquetas QUOTE y CODE
Responder Con Cita
  #2  
Antiguo 06-03-2009
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Cita:
Empezado por torrescrack9 Ver Mensaje
debo dimensionar un vector y he probado de un monton de formas y no soi capaz me da un error....
Código:
short vector;
short vectorentrada;
..........
..........
vector.redim(repeticiones);
vectorentrada.redim(repeticiones);
El error que me sale es el siguiente:
---structure required on left side of. or .
--- invalid direction
Pues un short no es una clase y no tiene un miembro que se llame redim, por lo tanto no te compila.

Imagino que lo que quieres es usar el template vector asi:

Código:
#include <vector> 
...
...
std::vector<short> Vector(repeticiones); 
std::vector<short> VectorEntrada(repeticiones);
Saludos.
Responder Con Cita
  #3  
Antiguo 06-03-2009
torrescrack9 torrescrack9 is offline
Registrado
 
Registrado: feb 2009
Posts: 5
Poder: 0
torrescrack9 Va por buen camino
he probado con eso que me as puesto y me sigue saliendo un error en la funcion inicio:
el otro error de dimensionar el vector ya creo q lo e solucionado xq no me salen errores

Código:
void inicio()
{
//int i;
std::vector<short> Vector(repeticiones); 
std::vector<short> VectorEntrada(repeticiones);
for(i=1;i<repeticiones;i++)
{
/// aki me da el error siguiente: invalid direction
vector[i] = aleatorio(limiteinf,limitesup); 
}
Form2->I_1->Enabled=false;
Form2->I_2->Enabled=false;
Form2->I_3->Enabled=false;
Form2->I_4->Enabled=false;
Form2->Juego1->Enabled=false;
Form2->Acerca1->Enabled=false;
Form2->Secuenciador->Enabled=true;
contador=1;
}

Última edición por dec fecha: 06-03-2009 a las 14:54:51. Razón: Poner las etiquetas CODE
Responder Con Cita
  #4  
Antiguo 06-03-2009
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
el template se llama vector, por eso te cambié los nombres a Vector y VectorEntrada. C y C++ son sensibles a mayúsculas, esto quiere decir que vector y Vector no es lo mismo.

...así que cambia tu variable vector a Vector y vectorentrada a VectorEntrada. Esta última no hace falta, pero la camibé por estética y congruencia sintáctica con su "hermana"

Saludos.
Responder Con Cita
  #5  
Antiguo 07-03-2009
torrescrack9 torrescrack9 is offline
Registrado
 
Registrado: feb 2009
Posts: 5
Poder: 0
torrescrack9 Va por buen camino
weno lo e intentao pro no lo consigo me sigue saliendo el mismo error que antes....
mira voi a poner el codigo dnd me da el fallo aver si sq tngo algo mal inicializado o mal escrito o algo.....

CODIGO VARIABLES
#include <vcl.h>
#pragma hdrstop
#include <Vector>
#include "Unit2.h"

int repeticiones;
int contador;
int Vector;
int i;
const short limiteinf=1;
const short limitesup=4;



CODIGO FUNCION

void inicio()
{
//int i;
std::vector<short> Vector(repeticiones);
std::vector<short> VectorEntrada(repeticiones);
//vector.redim(repeticiones);
//vectorentrada.redim(repeticiones);
for(i=1;i<repeticiones;i++)
{
Vector[i]=aleatorio(limiteinf,limitesup); // En esta linea es dnd me da el siguiente error: "Not an allowed type" y "Undefined symbol 'vector'"
}
Form2->I_1->Enabled=false;
Form2->I_2->Enabled=false;
Form2->I_3->Enabled=false;
Form2->I_4->Enabled=false;
Form2->Juego1->Enabled=false;
Form2->Acerca1->Enabled=false;
Form2->Secuenciador->Enabled=true;
contador=1;
}
Responder Con Cita
  #6  
Antiguo 07-03-2009
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Código:
#include <vcl.h>
#pragma hdrstop
#include <Vector>
#include "Unit2.h"
int repeticiones;
int contador;
// int Vector;  Vector no es un entero, es un template que inicializas en inicio
int i;
const short limiteinf=1;
const short limitesup=4;
 
 
CODIGO FUNCION
 
void inicio()
{
 //int i;
 std::vector<short> Vector(repeticiones);
 std::vector<short> VectorEntrada(repeticiones);
 //vector.redim(repeticiones);   // redim no es miembro del template vector
 //vectorentrada.redim(repeticiones);
 for(i=1;i<repeticiones;i++)
 {
   Vector[i]=aleatorio(limiteinf,limitesup); // En esta linea es dnd me da el     siguiente error: "Not an allowed type" y "Undefined symbol 'vector'" 
   // El error es porque lo declaraste antes como int
 }
 ......
......
}
Saludos
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
juego c++ builder torrescrack9 Gráficos 2 27-02-2009 17:34:17
juego c++ builder torrescrack9 C++ Builder 1 26-02-2009 19:52:07
instalacion de zeos lib en c++ builder 2007 2-D@monic C++ Builder 0 18-05-2008 06:55:52
C++ Builder 2007 rruz Noticias 0 15-05-2007 08:39:33
Duda sobre como programar el juego Timbiriche mifiar Varios 16 26-11-2005 06:06:01


La franja horaria es GMT +2. Ahora son las 05:57:20.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi