[help] style of object creation in C++

Hello,
I met a statement like the following. But I don't know whether the statement of object creation is ok.
1
2
3
4
5
6
   class Fraction{
      private:
           .........
      public:
           Fraction(){}
   };
   int main(){
       Fraction a();//I don't know this statement is ok
       return 0;
   }
   
I don't know this statement is ok
It defines a function [prototype] a that returns an object of type Fraction with no parameter.
This is something that often confuses people. Fraction a(); looks as though it ought to create an object using the default constructor, but it doesn't. In fact, as coder777 says, it declares a function.

To create an object using the default constructor, just do:

Fraction a;
Topic archived. No new replies allowed.