Hi!I'm working on a project at university and I need your help!I have to make a class Image that will represent the image's pixels either using th RGB scale or the gray one. The existing classes are RGBpixel and graypixel.I think I have to do it using templates,so generic functions such as getPixel and setPixel that will impose the value of a pixel at particular coordinates. Can you tell me how I create array of objects in the class "Image" and then the generic functions?Do I have to use pointers to the objects?I'm confunsed..:((if you have an idea,it would be really helpful!
xcktinios
0
Newbie Poster
Recommended Answers
Jump to PostDepending on the problem use a template parameter. But the trick is to use a common base class.
Imagen this:
class pixelBase { // ... Stuff ... virtual void setPixel(); }; template<int pixelType> class pixelItem : public pixelBase { virtual void setPixel(...); };
This doesn't always …
All 4 Replies
StuXYZ
731
Practically a Master Poster
thelamb
163
Posting Pro in Training
xcktinios
0
Newbie Poster
StuXYZ
731
Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.