May 22, 2019 at 8:29pm UTC
Hi guys! I have a problem that i hope you give me an advice to solve it. I have writing this code and it doesn't run cuz its a problem.
C2562 'Draw':'void' function returning a vaue.....
I dont know what to correct.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#include <iostream>
using namespace std;
bool gameOver;
const int width = 20;
const int height = 20;
int x, y, fruitX, fruitY, score;
enum eDirection {STOP = 0, LEFT, RIGHT, UP, DOWN};
eDirection dir;
void Setup()
{
gameOver = false ;
dir = STOP;
x = width / 2;
y = height / 2;
fruitX = rand() % width;
fruitY = rand() % height;
score = 0;
}
void Draw()
{
system("cls" ); // system clear;
for (int i = 0; i < width; ++i)
cout << "#" ;
cout << endl;
for (int i = 0; i < height; ++i)
{
for (int j = 0; j < width; j++)
{
if (j == 0)
cout << "#" ;
cout << "" ;
if (j == width - 1)
cout << "#" ;
}
cout << endl;
}
}
thank u!
Last edited on May 23, 2019 at 7:04am UTC
May 23, 2019 at 7:05am UTC
This is the problem: "C2562 'Draw':'void' function returning a vaue"
May 23, 2019 at 7:59am UTC
slim wrote:I dont know what to correct.
The code you provided doesn't cause the error you claim. So
you have muddled your files somehow .
Here is your function Draw(). It does not contain the word "return" anywhere.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
void Draw()
{
system("cls" ); // system clear;
for (int i = 0; i < width; ++i)
cout << "#" ;
cout << endl;
for (int i = 0; i < height; ++i)
{
for (int j = 0; j < width; j++)
{
if (j == 0)
cout << "#" ;
cout << "" ;
if (j == width - 1)
cout << "#" ;
}
cout << endl;
}
}
Last edited on May 23, 2019 at 8:23am UTC
May 23, 2019 at 1:49pm UTC
Show a complete example that reproduces your issue, else you're just wasting time.
And actually copy the error message(s). You clearly didn't do this, because you misspelled 'value' both times.
Last edited on May 23, 2019 at 1:49pm UTC