Cześć, mam problem z podzieleniem programu na pliki, niby wszystko dobrze według tego co znalazłem na necie. Mam trzy pliki:
main.cpp
#include "base.hpp"
//********************************************************
int main()
{
gotoxy(2,2);
cout << "Abc";
return 0;
}
//********************************************************
base.cpp
#include "base.hpp"
//********************************************************
//********************************************************
inline void color(short id){
HANDLE color;
color = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(color, id);
}
//********************************************************
inline void gametitle(){
color (8);
cout << "******************************" << endl;
cout << "* Grzybki v1, by adamowski10 *" << endl;
cout << "******************************" << endl;
}
//********************************************************
inline void gotoxy(int x, int y){
COORD c;
c.X = x - 1;
c.Y = y + 2; // plus dwa, bo 3 linijki naglowka
SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
}
//********************************************************
inline void drawmenu(short id){
system ("CLS");
gametitle();
byte active = 3; // kolor czcionki aktywnej
byte deactive = 8; // kolor czcionki nieaktywnej
color(deactive);
cout << "* *" << endl;
cout << "* *" << endl;
cout << "* *" << endl;
cout << "******************************" << endl;
gotoxy(5,1);
if (id == 1){color(active);}else {color (deactive);}
cout << " 1. Start";
gotoxy(5,2);
if (id == 2){color(active);}else {color (deactive);}
cout << " 2. Informacje";
gotoxy(5,3);
if (id == 3){color(active);}else {color (deactive);}
cout << " 3. Wyjscie";
gotoxy(1,4);
}
//********************************************************
inline void menu(){
byte id = 1;
bool loop = true;
char key;
drawmenu (1);
while (loop == true){
// sterowanie menu
key = getch();
switch (key){
case 72:
if (id>1){id--;}
break;
case 80:
if (id<3){id++;}
break;
}
drawmenu (id);
}
}
//********************************************************
bool exit(){
system("cls");
color (2);
cout << "******************************" << endl;
cout << "* ";
color (11);
cout << "Grzybki v1, by adamowski10";
color (2);
cout << " *" << endl;
cout << "******************************" << endl;
cout << "* Czy na pewno chcesz *" << endl;
cout << "* mnie opuscic? ;c t/n *" << endl;
cout << "******************************" << endl;
char button = getch();
if ((button == 't') or (button == 'T')){
return 1;
} else return 0;
}
base.hpp
#ifndef BASE_HPP_INCLUDED
#define BASE_HPP_INCLUDED
#include <iostream> // wejscie, wyjscie, wypisywanie tekstu
#include <windows.h> // system (), sleep()
#include <conio.h> // getch()
#include <string> // znaki
#include <cstdlib> // losowanie
#include <time.h>
#include <ctime>
#include <vector> // tablice dynamiczne
using namespace std;
inline void color(short id); // funcka zmieniajaca kolor czcionki
inline void gametitle(); // wyswietla naglowek w grze
inline void gotoxy(int x, int y);
inline void drawmenu(short id);
inline void menu();
bool exit();
#endif // BASE_HPP_INCLUDED
błędy programu:
||=== Build: Debug in Grzybki (compiler: GNU GCC Compiler) ===|
C:\Documents and Settings\Administrator\Pulpit\Grzybki\base.hpp|17|warning: inline function 'void gotoxy(int, int)' used but never defined [enabled by default]|
obj\Debug\main.o||In function `main':|
C:\Documents and Settings\Administrator\Pulpit\Grzybki\main.cpp|5|undefined reference to `gotoxy(int, int)'|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|
Codeblock