KEKS-KEKS
27-10-2007, 20:33
Код из самоучителя, всё переписал ошибки в двух строках выделенных жирным шрифтом.
initialization of 'Index' is skipped by 'case' label
J:\C++\Lesson 13\main.cpp(33) : see declaration of 'Index'
J:\C++\Lesson 13\main.cpp(47) : error C2361: initialization of 'Index' is skipped by 'default' label
J:\C++\Lesson 13\main.cpp(33) : see declaration of 'Index'
Error executing cl.exe.
main.obj - 2 error(s), 0 warning(s)
#include <iostream>
#include <exception>
#include "PromptModule.h"
#include "ErrorHandlingModule.h"
using namespace std;
char GetOperator(void)
{
char Operator;
cout<<"OPERATOR =";
cin>>Operator;
return Operator;
}
float GetOperand(void)
{
float Operand;
cout<<"OPERAND =";
cin>>Operand;
return Operand;
}
void Tape(const char theOperator,const int theOperand)
{
static const int myTapeChunk=3;
static char *myOperator=new char[myTapeChunk];
static int *myOperand=new int[myTapeChunk];
static int myTapeSize=myTapeChunk;
static int myNumberOfEntries=0;
switch (theOperator)
{
case '?':for
(
int Index=0; ОШИБКА
Index < myNumberOfEntries;
Index++
)
{
cout <<
myOperator[Index]<<","<<myOperand[Index]<<endl;
};
break;
case '.': ОШИБКА
delete [] myOperator;
delete [] myOperand;
break;
default : // dobavitj k lente i passhiritj 51
if (myNumberOfEntries == myTapeSize)
{
char *ExpendedOperator=new char[myNumberOfEntries+myTapeChunk];
int *ExpendedOperand=new int [myNumberOfEntries+myTapeChunk];
char *FromOperator=myOperator;
int *FromOperand=myOperand;
char *ToOperator=ExpendedOperator;
int *ToOperand=ExpendedOperand;
for
(
int Index = 0;
Index<myNumberOfEntries;
Index++
)
{
*ToOperator++= *FromOperator++;
*ToOperand++= *FromOperand++;
};
delete[] myOperator;
delete[] myOperand;
myOperator=ExpendedOperator;
myOperand=ExpendedOperand;
myTapeSize+=myTapeChunk;
};
myOperator[myNumberOfEntries]=theOperator;
myOperand[myNumberOfEntries]=theOperand;
myNumberOfEntries++;
};
}
initialization of 'Index' is skipped by 'case' label
J:\C++\Lesson 13\main.cpp(33) : see declaration of 'Index'
J:\C++\Lesson 13\main.cpp(47) : error C2361: initialization of 'Index' is skipped by 'default' label
J:\C++\Lesson 13\main.cpp(33) : see declaration of 'Index'
Error executing cl.exe.
main.obj - 2 error(s), 0 warning(s)
#include <iostream>
#include <exception>
#include "PromptModule.h"
#include "ErrorHandlingModule.h"
using namespace std;
char GetOperator(void)
{
char Operator;
cout<<"OPERATOR =";
cin>>Operator;
return Operator;
}
float GetOperand(void)
{
float Operand;
cout<<"OPERAND =";
cin>>Operand;
return Operand;
}
void Tape(const char theOperator,const int theOperand)
{
static const int myTapeChunk=3;
static char *myOperator=new char[myTapeChunk];
static int *myOperand=new int[myTapeChunk];
static int myTapeSize=myTapeChunk;
static int myNumberOfEntries=0;
switch (theOperator)
{
case '?':for
(
int Index=0; ОШИБКА
Index < myNumberOfEntries;
Index++
)
{
cout <<
myOperator[Index]<<","<<myOperand[Index]<<endl;
};
break;
case '.': ОШИБКА
delete [] myOperator;
delete [] myOperand;
break;
default : // dobavitj k lente i passhiritj 51
if (myNumberOfEntries == myTapeSize)
{
char *ExpendedOperator=new char[myNumberOfEntries+myTapeChunk];
int *ExpendedOperand=new int [myNumberOfEntries+myTapeChunk];
char *FromOperator=myOperator;
int *FromOperand=myOperand;
char *ToOperator=ExpendedOperator;
int *ToOperand=ExpendedOperand;
for
(
int Index = 0;
Index<myNumberOfEntries;
Index++
)
{
*ToOperator++= *FromOperator++;
*ToOperand++= *FromOperand++;
};
delete[] myOperator;
delete[] myOperand;
myOperator=ExpendedOperator;
myOperand=ExpendedOperand;
myTapeSize+=myTapeChunk;
};
myOperator[myNumberOfEntries]=theOperator;
myOperand[myNumberOfEntries]=theOperand;
myNumberOfEntries++;
};
}