You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structTest
{
Test opCall()
{
returnTest();
}
}
voidmain()
{
Test(); // Error: calling non-static function `opCall` requires an instance of type `Test`
}
The call Test(); in the main function should be interpreted as default construction of a new Test instance. However, it is incorrectly interpreted as a static call to the non-static opCall defined in Test.
Note that this does not occur for classes, due to the required use of the new keyword to construct them.
If the struct or a union defines a no-arg constructor, the compiler will correctly interpret Test() as a call to an illegal no-arg constructor and report an error. If it defines an N-arg constructor, the compiler will interpret Test() as a new default-initialized instance of Test.
The text was updated successfully, but these errors were encountered:
The call
Test();
in the main function should be interpreted as default construction of a newTest
instance. However, it is incorrectly interpreted as a static call to the non-staticopCall
defined inTest
.Note that this does not occur for classes, due to the required use of the
new
keyword to construct them.If the struct or a union defines a no-arg constructor, the compiler will correctly interpret
Test()
as a call to an illegal no-arg constructor and report an error. If it defines an N-arg constructor, the compiler will interpretTest()
as a new default-initialized instance ofTest
.The text was updated successfully, but these errors were encountered: