Consider the following program:
#include <iostream>
struct Test
{
int a;
Test(int s) : a(s)
{ };
int geta()
{
return a;
}
};
int main()
{
Test t(3);
std::cout<<t.geta()<<'\n';
}
The program compiles fine even when I use the parameter in -pedantic-errorsboth gcc and clang. (See the demo here and here .) I also donβt get any error from the compiler if I put a semicolon at the end of the geta () function, as shown below:
int geta()
{
return a;
};
So what is the purpose of resolving this unnecessary semicolon? Is there any use for this? Is this explicitly permitted by locale?
source
share