Witam, mam problem z ów programem, siedziałem dzisiaj pół dnia nad tym jednym problemem, ale nie potrafię sobie z tym już poradzić. Podczas kompilacji (za pomocą 'gcc') wyskakuje mi błąd:
main.cpp: In function ‘int main()’:
main.cpp23: error: no match for call to ‘(Image) (int&, int&)’
skakałem, latałem, ale już nie mam siły i nie wiem co tutaj mam zrobić. Komenda jaką wpisywałem do terminala to:
g++ main.cpp -g -Wall -pedantic -o main.out
Oddam duszę za pomoc.
Program aktualnie nie jest dokonczony, ale to raczej nie powoduje błędów przy kompilacji.
//Image.h
#include <iostream>
#ifndef IMAGE_H
#define IMAGE_H
typedef unsigned char byte;
class Image
{
public:
Image();
Image(int width, int height);
Image(const Image& c_Image);
//Image& operator=(const Image& c_Image);
void fillInImage(byte value);
byte getPix(int pix_w, int pix_h);
void fillPix(int pix_w, int pix_h, byte value);
int getWidth();
int getHeight();
void createImage(int n_width_top, int n_height_top, int n_width_bottom, int n_height_bottom);
void showImage();
~Image();
private:
int width_p;
int height_p;
byte **tab;
};
#endif
//Image.cpp
#include <iostream>
#include "Image.h"
using namespace std;
Image::Image(){}
Image::Image(int width, int height) : width_p(width), height_p(height)
{
this->tab=new byte*[width_p];
for(int i=0; i<width_p; i++)
this->tab[i]=new byte[height_p];
}
Image::Image(const Image& c_Image)
{
this->width_p=width_p;
this->height_p=height_p;
for(int i=0; i<width_p; i++)
{
for(int j=0; j<height_p; j++)
this->tab[i][j]=tab[i][j];
}
}
/*Image& Image::operator=(const Image& c_Image)
{
}*/
void Image::fillInImage(byte value)
{
for(int i=0; i<width_p; i++)
{
for(int j=0; j<height_p; j++)
tab[i][j]=value;
}
}
byte Image::getPix(int pix_w, int pix_h)
{
return tab[pix_w][pix_h];
}
void Image::fillPix(int pix_w, int pix_h, byte value)
{
tab[pix_w][pix_h]=value;
}
int Image::getWidth()
{
return width_p;
}
int Image::getHeight()
{
return height_p;
}
void Image::createImage(int n_width_top, int n_height_top, int n_width_bottom, int n_height_bottom)
{
Image n_Image(n_width_bottom-n_width_top, n_height_bottom-n_height_top);
for(int i=n_width_top; i<n_width_bottom; i++)
{
for(int j=n_height_top; j<n_width_bottom; j++)
n_Image.fillPix(i, j, tab[i][j]);
}
}
void Image::showImage()
{
for(int i=0;i<width_p;i++)
{
for(int j=0;j<height_p;j++)
cout << tab[i][j];
cout << endl;
}
}
Image::~Image()
{
for(int i=0; i<height_p; i++)
delete [] tab[i];
delete [] tab;
}
//main.cpp <-- główny program
#include <iostream>
#include "Image.h"
using namespace std;
int main()
{
int opt;
int width, height;
Image obraz;
cout << "Program implementuje dwywymiarowy obraz monochromatyczny"<<endl;
cout << "Menu:" << endl;
cout << "1. Inicjalizacja obrazu (konstruktor)" << endl;
cout << "2. Inicjalizacja koloru obrazu (jednolity)" << endl;
cout << "3. Odczyt piksela (odcien)" << endl;
cout << "4. Zapis piksela (pojedynczy)" << endl;
cout << "5. Rozdzielczość obrazu" << endl;
cout << "6. Skopiowanie obrazu (konst. kopiujacy)" << endl;
cout << "7. Kopia fragmentu obrazu. " << endl;
cout << "8. Wyswietlenie obrazu." << endl;
cout << "0. Zamkniecie aplikacji.";
cout << "Wybierz opcję: ";
cin >> opt;
do
{
switch(opt)
{
case 1:
cout<<"Inicjalizacja obrazu (dzialanie konstruktora)" << endl;
cout<<"Podaj szerokosc obrazu: ";
cin >> width;
cout<<"Podaj wysokosc obrazu: ";
cin >> height;
obraz(width, height);
break;
}
}while(opt==0);
return 0;
}