When I wrote the interface in Visual Studio 2015, I noticed some strange behavior. Normally, placing the keyword "virtual" in front of a function identifier does not matter, but if it is placed after a pointer or reference, it complains. See the following:
class B {}; class A { virtual B fun1a(); // OK B virtual fun1b(); // OK virtual B& fun2a(); // OK B& virtual fun2b(); // ERROR, "expected an identifier" virtual B* fun3a(); // OK B* virtual fun3b(); // ERROR, "expected an identifier" virtual std::unique_ptr<B> fun4a(); // OK std::unique_ptr<B> virtual fun4b(); // OK };
Why is this?
And, obviously, I can completely avoid errors by always setting the virtual keyword first, but I would like to write function descriptions as follows:
foo const & // return value and relevant keywords on one line virtual bar( const baz &a ) const // function identifier, arguments, and relevant keywords on another line { /* method implementation */ }
Alas, this is not possible for functions that return a link or pointer ...
Is this syntax error linguistic or visual studio localized?
source share