drawRectangle() ISSUE!

Hello, before I explain my problem I just wanted to say that I am quiet new to the programming.

I'll be quick and just describe the problem really briefly, I am attempting to create simple rectangle ( square ) on win32 application. I am using CodeBlocks and We have been provided with own library which include <windows.h>.

However when I try to create rectangle using this function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <snake.hpp>
#include "intro_state.hpp"
#include <windows.h>
#include <vector>

void drawRectangle(Pen* pen, int x, int y, int width, int height)
{
    Pen greenPen = new Pen(Color.Green, 3);
    int x = 20;
    int y = 20;
    int width = 200;
    int height = 200;

    // Draw rectangle to screen
    drawRectangle(greenPen, x, y, width, height)
}


I get this error:
1
2
..\..\inc\snake.hpp|13|error: 'Pen' has not been declared|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|




My header file for this particular function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef _LEVEL_HPP_
#define _LEVEL_HPP_

#include <intro_state.hpp>
#include <vector>
#include <windows.h>
#include <sstream>
#include <string>

class Snake
{
public:
    void drawRectangle(Pen pen, int x, int y, int width, int height);
};

#endif // _LEVEL_HPP_ 


I really hope you guys can help me! I'd really appreciate it.
Thank you
opProgrammer wrote:
and We have been provided with own library

What library are you on about.

I see two immediate issues

1. In this first code, this function appears to be infinite recursive
1
2
3
4
5
6
7
8
9
10
11
void drawRectangle(Pen* pen, int x, int y, int width, int height)
{
    Pen greenPen = new Pen(Color.Green, 3);
    int x = 20;
    int y = 20;
    int width = 200;
    int height = 200;

    // Draw rectangle to screen
    drawRectangle(greenPen, x, y, width, height) //also missing semicolon here.
}



2. If the function above is supposed to be the definition (also known as the body) for this function declaration here from the Snake class:
1
2
3
4
5
class Snake
{
public:
    void drawRectangle(Pen pen, int x, int y, int width, int height);
};

then the function definition is incorrect
it should be
1
2
3
4
5
6
7
8
9
10
void Snake::drawRectangle(Pen* pen, int x, int y, int width, int height)
{
     void drawRectangle(Pen* pen, int x, int y, int width, int height)
{
    Pen greenPen = new Pen(Color.Green, 3);
    int x = 20;
    //...... other code here
    
}
}



But we are still stuck with the definition/declaration of Pen.
Where (in what header file) is the declaration for Pen ???????
Last edited on
What I mean't by saying "own library " is that our tutor have provided functions specially designated for our project. Which is very, very similar to <windows.h> library.

Coming back to the Pen, I thought its part of GDI library?
Last edited on
I would really appreciate any help or just a point into right direction to resolve this issue .

Thank you !
Topic archived. No new replies allowed.