Witam. Napotkałem problem z klasami mianowicie poniższy kod wyrzuca błąd:
Poniżej kod programu:
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
struct header {
char magicNumb[2];
int width;
int height;
int grayScale;
};
class image
{
public:
header _header;
string fileName;
int **img;
void set_header(std::string MN, int width, int height, int GS, string Fname)
{
this->fileName = Fname;
this->_header.magicNumb[0] = MN[0];
this->_header.magicNumb[1] = MN[1];
this->_header.width = width;
this->_header.height = height;
this->_header.grayScale = GS;
};
void create_table_of_img(int valWidth, int valHeight)
{
this->img = new int*[valWidth];
for (int i = 0; i < valHeight; ++i) {
this->img[i] = new int[valHeight];
}
}
void delete_table()
{
for (int i = 0; i < this->_header.width; ++i) {
delete[] this->img[i];
}
delete[] img;
}
void print_table()
{
for (int x = 0; x < this->_header.width; x++)
{
for (int y = 0; y < this->_header.height; y++)
{
std::cout << img[x][y]<<" ";
}
std::cout << "\n";
}
}
void print_header()
{
cout << "File name : " << fileName;
printf("File name: %s", this->fileName);
printf("magicNumb: %c%c", this->_header.magicNumb[0], this->_header.magicNumb[1]);
printf("\nWidth: %i", this->_header.width);
printf("\nheight: %i", this->_header.height);
printf("\ngrayScale: %i", this->_header.grayScale);
};
void read_file()
{
fstream file;
file.open(this->fileName, ios::out | ios::app | ios::binary);
}
};