template <class PixelType>
class Scanline
{
public:
Scanline(std::vector<PixelType>::size_type size) //error
{
while (pixels.size() < size)
{
pixels.push_back(0);
}
}
PixelType& operator[](int x)
{
return pixels[x];
}
private:
std::vector<PixelType> pixels;
};
It's been so long since I used C++...
[edit: someone deleted their post]
[sad]
I thought that was how you declared constructors in C++.
[sad]
I thought that was how you declared constructors in C++.
Yeah, you're right; I wasn't paying attention. I don't see a problem, but then I haven't used C++ in a year or so.
MSVC7.1 (.NET 2003) insists on a typename keyword, other than that it compiles fine.
Scanline(typename std::vector<PixelType>::size_type size)
In standard-compliant compilers, the "typename" keyword MUST be used to distinguish typenames from static constants within the context of a template. So, where you used "std::vector<PixelType>::size_type", you should add the typename keyword in front of it. I would personally typedef this as well, like the following snippet of code.
template <class PixelType>class Scanline{public: typedef typename std::vector<PixelType>::size_type size_type; Scanline(size_type size) { while (line.size() < size) { pixels.push_back(0); } } PixelType& operator[](size_type x) { return pixels[x]; }private: std::vector<PixelType> pixels;};
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement