error LNK2019

I'm creating an image manipulation program and created two classes, pixel and image. The pixel class works fine and I can do everything with it, from inversing the colors to brightening to greyscale. I wanted to have an image class that uses the pixel class instead of being in the main cpp file. I get however the error "error LNK2019: unresolved external symbol "public: __thiscall pixel::pixel(void)" (??0pixel@@QAE@XZ) referenced in function "public: __thiscall image::image(void)" (??0image@@QAE@XZ)"

Image header file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "pixel.h"
#ifndef IMAGE_H
#define IMAGE_H
class image
{
public:
	//constructors
	image();
	image(int,int);
	//Member functions
	///Accessors
	int getpixel(int);
private:
	int width;
	int height;
	pixel* contents;
};
#endif 

image implementation file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "pixel.h"
#include "image.h"
#include <iostream>
using namespace std;

image::image()
{
	width=100;
	height=100;
	pixel* contents=new pixel[width*height];
}
image::image(int num1, int num2)
{
	width=num1;
	height=num2;
}
int image::getpixel(int num)
{
	return contents[num].getblue();
}


main function
1
2
3
4
5
6
7
8
9
#include "image.h"
#include "pixel.h"
#include <iostream>
using namespace std;

void main()
{
	image diaa;
}

Post pixel.h and pixel.cpp
It seems that you declared but not defined your pixels default constructor, but I can't be sure until you post the code.
Topic archived. No new replies allowed.