class word in parameters

Hello,

Could you please tell me why put the "class" word in front of Visitor* in the code below and why not just put virtual void accept(Visitor*)=0;
?

Thank you in advance

1
2
3
4
5
class Color
{
	public:
		virtual void accept(class Visitor*)=0;
};
You wouldn't do this.
Where is this "example" from?
I think in C you might be required to do this with a struct, but certainly not in c++.
Last edited on
It is optional in C++, as it is a carry-over from C - C++ treats the struct and class keywords the same (aside from default privacy settings). Typically you might see code like this from a C developer transitioning into C++. It may also be a shortcut syntax for avoiding forward declaration (though that's just excessively lazy):
http://ideone.com/2Zk6oK
Topic archived. No new replies allowed.