Network RPG Maker
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.

Network RPG Maker

Aide Professionnelle pour N-RPG Maker, RM2003/XP et 3D Rpg Builder
 
AccueilAccueil  PortailPortail  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  Connexion  
-50%
Le deal à ne pas rater :
WiMiUS S27 – Mini projecteur portable rotatif à 270° Full HD 9000 ...
69.99 € 139.99 €
Voir le deal

 

 Aide C++

Aller en bas 
2 participants
AuteurMessage
jefft
lvl 3



Nombre de messages : 54
Date d'inscription : 13/08/2005

Aide C++ Empty
MessageSujet: Aide C++   Aide C++ EmptySam 8 Avr - 2:47

Hello les gars ^^
Je reviens, avec genre, euh, 7 fois plus de connaissances en prog qu'avant Mr.Red
Pour infos, j'ai 11 ans maintenant et je développe plusieurs logiciels php.
Mais là je commence avec C++ mais bon... chui même pas encore foutu de faire un programme de plus de 300 lignes sans que la compilation plante...
Voiçi mon programme:
CPoint.h
Code:

struct Point
{
   Point(); x = 0; y = 0;
   Point(int ix, int iy) x = ix; y iy;
   int x;
   int y;
}
CRect.h
Code:


#include "CPoint.h"

struct Rect
{
   Rect()(m_ptTopLeft = Point(); m_ptBotRight = Point(10, 10););
   Rect(Point tl, Point fr) ( m_ptTopLeft = tl; m_ptBotRight =br; );

   Point m_ptTopLeft;
   Point m_ptBotRight;

   void SetRect(Point tl, Point br) ( m_ptTopLeft = tl; m_ptBotRight = br; );
   void SetRect(int x1, int y1, int x2, int y2){
      m_ptTopLeft.x = x1; m_ptTopLeft.y = y1;
      m_ptBotRight.x = x2; m_ptBotRight.y = y2;
   };
};
Shape.h
Code:

#include "CRect.h"

const int NUM_TYPES = 2;

enum ShpType
{
   shpRectangle,
   shpEllipse
};

struct Shape
{
   Rect m_rectShape;
   ShpType m_typeShape;
};
Shape1.cpp
Code:

#include"Shape.h"
#include<stdio.h>
#include<assert.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>

void DrawShape(Shape* pS);
void MoveShape(Shape* pS, Point p);
int RandomCoord();
ShpType RandomType();

const int COORD_MAX = 1000;

int main(int argc, char* argv[])
{
   Shape shp1;
   shp1.m_recShape = Rect(Point(20, 20), Point(50, 50));
    shp1.m_typeShape = shpRectangle;
   DrawShape(&shp1);

   MoveShape(&shp1, Point(25, 25));
   DrawShape(&shp1);

   Shape* pShp2 = new Shape;
   assert(pShp2 != NULL);
   pShp2->m_typeShape = shpEllipse;
   DrawShape(pShp2);

   delete pShp2;

   Point pt1, pt2;
   Shape* arShps[20];
   srand((unsigned)time(NULL));
   for(int i = 0; i < 20; i++)
   {
      Shape* pShp = new Shape;
      assert(pShp != NULL);
      pt1 = Point(RandomCoord(), RandomCoord());
      pt2 = Point(RandomCoord(), RandomCoord());
        pShp->m_rectShape = Rect(pt1, pt2);
      pShp->m_rectShape = RandomType();
      arShps[i] = pShp;
      DrawShape(arShps[i]);
   }
    MoveShape(arShps[0] Point(20, 20))
   DrawShape(arShps[0]);
   for(int j = 0; j < 20; j++) delete arShps[j];

   return 0;
}

void DrawShape(Shape* pS)
{
   Rect rect = pS->m_rectShape;
   int x1 = rect.m_ptTopLeft.x;
    int y1 = rect.m_ptTopLeft.y;
   int x2 = rect.m_ptBotRight.x;
   int y2 = rect.m_ptBotRight.y;

   char szType[20];
   switch(pS->m_typeShape)
   {
   case shpRectangle: strcpy(szType, "rectangle");
      break;
    case shpEllipse: sprintf(szType, "%s", "ellipse");
      break;
   default: strcpy(szType, "erreur type de figure");

   };

   printf("%s à(%d, %d, %d, %d)\n", szType, x1, y1, x2, y2);
}
void MoveShape(Shape* pS, Point p){
   Rect rect = pS->m_rectShape;
   int width = abs(rect.m_ptBotRight.x - rect.m_ptTopLeft.x);
    int height = abs(rect.m_ptBotRight.y - rect.m_ptTopLeft.y);
    pS->m_rectShape.m_ptTopLeft = p;
   pS->m_rectShape.m_ptBotRight = Point(p.x + width, p.y + height);
}

int RandomCoord()
{
   static int nLastCoord;
   int nNextCoord = rand();
   int nFuge = rand() % 100;

   nLastCoord = (nNextCoord > nLastCoord ? nNextCoord : nLastCoord);
   nLastCoord = (nLastCoord + nFudge) % COORD_MAX
      return nLastCoord;
}

ShpType RandomType()
{
   return (ShpType)(rand() % NUM_TYPES);
}
Le compilateur renvoie:
Code:

--------------------Configuration: shape1 - Win32 Debug--------------------
Compiling...
Shape1.cpp
C:\Msdev\Projects\Shape1\CPoint.h(3) : error C2501: 'x' : missing decl-specifiers
C:\Msdev\Projects\Shape1\CPoint.h(3) : error C2501: 'y' : missing decl-specifiers
C:\Msdev\Projects\Shape1\CPoint.h(4) : error C2059: syntax error : 'identifier'
C:\Msdev\Projects\Shape1\CPoint.h(4) : error C2146: syntax error : missing ';' before identifier 'x'
C:\Msdev\Projects\Shape1\CPoint.h(4) : error C2065: 'ix' : undeclared identifier
C:\Msdev\Projects\Shape1\CPoint.h(4) : error C2258: illegal pure syntax, must be '= 0'
C:\Msdev\Projects\Shape1\CPoint.h(4) : error C2501: 'x' : missing decl-specifiers
C:\Msdev\Projects\Shape1\CPoint.h(4) : error C2501: 'y' : missing decl-specifiers
C:\Msdev\Projects\Shape1\CPoint.h(4) : error C2146: syntax error : missing ';' before identifier 'iy'
C:\Msdev\Projects\Shape1\CPoint.h(4) : error C2501: 'iy' : missing decl-specifiers
C:\Msdev\Projects\Shape1\CRect.h(5) : error C2236: unexpected 'struct' 'Rect'
C:\Msdev\Projects\Shape1\CRect.h(5) : error C2143: syntax error : missing ';' before '{'
C:\Msdev\Projects\Shape1\CRect.h(5) : error C2447: missing function header (old-style formal list?)
C:\Msdev\Projects\Shape1\CRect.h(17) : error C2143: syntax error : missing ';' before '}'
C:\Msdev\Projects\Shape1\Shape.h(13) : error C2501: 'Rect' : missing decl-specifiers
C:\Msdev\Projects\Shape1\Shape.h(13) : error C2146: syntax error : missing ';' before identifier 'm_rectShape'
C:\Msdev\Projects\Shape1\Shape.h(13) : error C2501: 'm_rectShape' : missing decl-specifiers
C:\Msdev\Projects\Shape1\Shape1.cpp(18) : error C2039: 'm_recShape' : is not a member of 'Shape'
C:\Msdev\Projects\Shape1\Shape1.cpp(18) : error C2065: 'Rect' : undeclared identifier
C:\Msdev\Projects\Shape1\Shape1.cpp(18) : error C2064: term does not evaluate to a function
C:\Msdev\Projects\Shape1\Shape1.cpp(41) : error C2039: 'm_rectShape' : is not a member of 'Shape'
C:\Msdev\Projects\Shape1\Shape1.cpp(41) : error C2064: term does not evaluate to a function
C:\Msdev\Projects\Shape1\Shape1.cpp(42) : error C2039: 'm_rectShape' : is not a member of 'Shape'
C:\Msdev\Projects\Shape1\Shape1.cpp(46) : error C2146: syntax error : missing ')' before identifier 'Point'
C:\Msdev\Projects\Shape1\Shape1.cpp(46) : error C2660: 'MoveShape' : function does not take 1 parameters
C:\Msdev\Projects\Shape1\Shape1.cpp(55) : error C2146: syntax error : missing ';' before identifier 'rect'
C:\Msdev\Projects\Shape1\Shape1.cpp(55) : error C2065: 'rect' : undeclared identifier
C:\Msdev\Projects\Shape1\Shape1.cpp(55) : error C2039: 'm_rectShape' : is not a member of 'Shape'
C:\Msdev\Projects\Shape1\Shape1.cpp(56) : error C2065: 'm_ptTopLeft' : undeclared identifier
C:\Msdev\Projects\Shape1\Shape1.cpp(56) : error C2065: 'x' : undeclared identifier
C:\Msdev\Projects\Shape1\Shape1.cpp(57) : error C2065: 'y' : undeclared identifier
C:\Msdev\Projects\Shape1\Shape1.cpp(58) : error C2065: 'm_ptBotRight' : undeclared identifier
C:\Msdev\Projects\Shape1\Shape1.cpp(75) : error C2146: syntax error : missing ';' before identifier 'rect'
C:\Msdev\Projects\Shape1\Shape1.cpp(75) : error C2039: 'm_rectShape' : is not a member of 'Shape'
C:\Msdev\Projects\Shape1\Shape1.cpp(78) : error C2039: 'm_rectShape' : is not a member of 'Shape'
C:\Msdev\Projects\Shape1\Shape1.cpp(79) : error C2039: 'm_rectShape' : is not a member of 'Shape'
C:\Msdev\Projects\Shape1\Shape1.cpp(89) : error C2065: 'nFudge' : undeclared identifier
C:\Msdev\Projects\Shape1\Shape1.cpp(90) : error C2143: syntax error : missing ';' before 'return'
Error executing cl.exe.
shape1.exe - 38 error(s), 0 warning(s)

Ils disent que j'oublie des ";" mais sinon ça ne fonctionnera pas!
Revenir en haut Aller en bas
Tony333
Programmeur / Maker
Programmeur / Maker
Tony333


Nombre de messages : 1697
Localisation : Rosny sous bois
Date d'inscription : 16/07/2005

Aide C++ Empty
MessageSujet: Re: Aide C++   Aide C++ EmptyDim 9 Avr - 16:11

gg Wink
Revenir en haut Aller en bas
 
Aide C++
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» a l'aide!!!
» aide
» Projet MMORPG
» de l'aide svp

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Network RPG Maker :: Coin membres :: Blah Blah !-
Sauter vers:  
Ne ratez plus aucun deal !
Abonnez-vous pour recevoir par notification une sélection des meilleurs deals chaque jour.
IgnorerAutoriser