Hello,
I trying to self-learn C++ and don't have much idea about header files. When I tried to create one as follows, I got a strange error that I do not understand. I have tried googling but my lack of understanding about C++ compiling/linking process is an obstacle.
Anyway, here is the header file (unnecessary code removed)
GraphicsLib.h
#ifndef GRAPHICS_LIB_INCLUDE
#define GRAPHICS_LIB_INCLUDE
enum BorderTypes
{
SINGLE_ALL,
DOUBLE_ALL,
SINGLE_SIDE_DOUBLE_TOP,
DOUBLE_SIDE_SINGLE_TOP
};
static void DrawMessageWithBox(std::string message, BorderTypes borderType, int length);
#endif // GRAPHICS_LIB_INCLUDE
The GraphicsLib.cpp file
include "GraphicsLib.h"
static void DrawMessageWithBox(string message, BorderTypes borderType, int length)
{
}
The main program
#include<iostream>
#include "GraphicsLib.h"
using namespace std;
int main()
{
DrawMessageWithBox("HELLO WORLD", BorderTypes.DOUBLE_ALL, 77);
return 0;
}
Whenever I try to compile the program, I get this error -
"[ERROR] Expected primary-expression before '.' token"
If I replace the function call with this one,
DrawMessageWithBox("HELLO WORLD", DOUBLE_ALL, 77);
I get the following error -
"[Warning] 'void DrawCenteredMessageWithBox(std::string, BorderTypes, int)' used but never defined [enabled by default]"
In function 'main':
"undefined reference to `DrawCenteredMessageWithBox(std::string, BorderTypes, int)' "
Can anyone please tell me what am I doing wrong?
Thanks.