klasy a funkcję

0

Jak mogę korzystać z funkcji nie należącej do klasy, w funkcji do niej należącej. Chodzi mi o fukncję gotoxy:

#include <iostream>
#include <windows.h>

using namespace std;


class postac
{
public:
    int x;
    int y;
    int funkcja(int &x, int &y);
    void gotoxy(int x, int y);
};

int main()
{

    postac bohater;

bohater.x = 10;
bohater.y = 10;

}

int funkcja(int &x, int &y)
{
gotoxy(32,11);


};

void gotoxy(int x, int y)
{
  COORD c;
  c.X = x - 1;
  c.Y = y - 1;
  SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
}
0

Masz zadeklarowane te funkcje w klasie przecież, więc w czym problem? Zaimplementuj je po prostu.

0
#include <iostream>
#include <windows.h>

using namespace std;


class postac
{
public:
    int x;
    int y;
    int funkcja(int &x, int &y);
    void gotoxy(int x, int y);
};

int main()
{

    postac bohater;

bohater.x = 10;
bohater.y = 10;

}

int postac::funkcja(int &x, int &y)
{
gotoxy(32,11);


};

void postac::gotoxy(int x, int y)
{
  COORD c;
  c.X = x - 1;
  c.Y = y - 1;
  SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
}
0

działa

1 użytkowników online, w tym zalogowanych: 0, gości: 1