#include <iostream>
#include <stdlib.h>
usingnamespace std;
//FP
int get_rand();
string get_figname(int);
int loop_check(bool fig[],int record,int randnum);
//begin of main
int main(int argc, char *argv[])
{
//dec var
int record = 0,total =0,randnum;
string figname;
bool fig[6];
//start loop
while(record != 6)
{
randnum = get_rand();
figname = get_figname(randnum);
total++;
//print out
cout<<total<<figname<<endl;
//if the condition change form false to true add 1
record = loop_check(fig,record,randnum);
}
cout<<"the simulation have ran "<<total<<" time"<<endl;
system("PAUSE");
return 0;
}
//end of main
//generate random number
int get_rand()
{
int num;
srand(time(NULL));
num = rand()%6;
return num;
}
//get action fig name
string get_figname(randnum)
{
switch (randnum)
case 0:return". Beet Farmer";
case 1:return". Bark Harvest";
case 2:return". turnip PUller";
case 3:return". Sugar Kettle Tender";
case 4:return". Box Filler";
case 5:return". Payroll Guard";
}
//check record
int loop_check(bool fig[],int record[],int randnum)
{
if (fig[randnum] == false)
{
fig[randnuum] = true;
return record++
}
elsereturn record;
}
those are my code and this is the error message i got
line 48 std::string get_figname redeclared as different kind of symbol
line 8 previous declaration of 'std::string get_figname[int]'
line 48 declaration of "std::string get_figname"
line 8 conflict with previous declartion "std::string get_figname[int]"
You declared get_figname as a function that takes an int and returns a string (line 8)
In your definition however the type of argument is not written so the compiler is confused.