Witam, moim celem jest odczytanie wartości, którą zwraca metoda receive() klasy klasa1. Chciałbym zrobić to przez wskaźnik ponieważ potrzebuje mieć możliwość nie tylko odczytania, ale też zmiany tej wartości w stworzonym obiekcie (obiekt1).
Poniższy kod powoduje błąd przy otwieraniu okna linii komend ( DEV C++)
#include <iostream>
#include <stdint.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class klasa1 {
private:
uint8_t RX;
typedef struct {
uint8_t ID;
uint8_t IN;
uint8_t P;
uint8_t C;
uint8_t D[4];
} Msg;
public:
klasa1()
{
RX = 13;
Msg RX[2];
RX[0].ID = 1;
RX[0].IN = 2;
RX[0].P = 3;
RX[0].C = 4;
RX[0].D[0] = 5;
RX[0].D[1] = 6;
RX[0].D[2] = 7;
RX[0].D[3] = 8;
RX[1].ID = 11;
RX[1].IN = 12;
RX[1].P = 13;
RX[1].C = 14;
RX[1].D[0] = 15;
RX[1].D[1] = 16;
RX[1].D[2] = 17;
RX[1].D[3] = 18;
};
uint8_t* receive()
{
uint8_t* wsk_RX;
*wsk_RX = RX;
return (wsk_RX);
}
};
class klasa_nadrzedna {
public:
klasa_nadrzedna()
{
klasa1* obiekt1;
uint8_t* zmienna;
uint8_t zm;
obiekt1 = new klasa1();
zmienna = obiekt1->receive();
printf("%d", obiekt1->receive());
};
};
int main(int argc, char** argv)
{
klasa_nadrzedna* obiekt_nadrzedny;
obiekt_nadrzedny = new klasa_nadrzedna();
system("pause");
return 0;
}