با سلام.
به يك مشكل برخورد كردم.
من يك هدر فايل مينويسم كه محتوياتش اينه و نام فايل crops.h هستش :
کد:#include <iostream>
#include <conio.h>
#include <string>
#include <cstdlib>
using namespace std;
class Crops
{
public :
void set_s ()
{
gamestatus=CONTINUE;
}
void tass1 (string starter)
{
switch (starter)
{
case "start":
case "Start":
case "ok":
for (int couter=0;(couter<=1 && gamestatus==CONTINUE);couter++)
{
int over1=0;
over1= 1+rand()%6;
cout<<"First the value is "<<over1<<endl;
main_over1=over1;
}
break;
case "exit":
case "Exit":
case "quit":
case "Quit":
getch();
break;
default :
cout<<"The value entered is failed!Please enter ((start)) to start or"
"((exit)) to quit !";
break;
}
}
void tass2 (string starter)
{
switch (starter)
{
case "start":
case "Start":
case "ok":
for (int couter2=0;(couter2<=1 && gamestatus==CONTINUE);couter2++)
{
int over2=0;
over2= 1+rand()%6;
cout<<"Second the value is "<<over2<<endl;
main_over2=over2;
}
break;
case "exit":
case "Exit":
case "quit":
case "Quit":
getch();
break;
default :
cout<<"The value entered is failded! Please enter ((start)) to start or ((exit)) to quit !";
break;
}
}
void set ()
{
main_overmain = main_over1+main_over2;
}
void sum ()
{
switch (main_overmain)
{
case 7:
case 11:
gamestatus=WON;
break;
case 2:
case 3:
case 12:
gamestatus=LOST;
break;
default:
gamestatus=CONTINUE;
break;
}
}
void answer ()
{
switch (gamestatus)
{
case WON :
cout<<"You WON!"<<endl;
break;
case LOST:
cout<<"You LOST!"<<endl;
break;
case CONTINUE :
cout<<"Please continue !"<<endl;
break;
}
}
private :
enum Status{WON,LOST,CONTINUE};
Status gamestatus;
int main_over1;
int main_over2;
int main_overmain;
}
و فايل سورس اون كه تابع main توشه اينطوري نوشته شده :
کد:#include "crops.h"
int main()
{
Crops mycrops;
string c_starter;
cout<<"Please enter ((start)) to start or ((exit)) to quit :";
getline(cin,c_starter);
mycrops.tass1(c_starter);
mycrops.tass2(c_starter);
mycrops.set();
mycrops.sum();
mycrops.answer();
getch();
return 0;
}
وقتي ميخوام كامپايل كنم visual c++ اين پيغام ها رو ميده :
کد:--------------------Configuration: Crops - Win32 Debug--------------------
Compiling...
main.cpp
f:\my c++ projects\crops\main.cpp(3) : error C2143: syntax error : missing ';' before 'PCH creation point'
Error executing cl.exe.
Crops.exe - 1 error(s), 0 warning(s)