Https://ide.codingblocks.com/s/240093

why is it giving error if i write graph g(); instead of graph g in main function?

this will give error as you have not made any constructor

and to make object of class we need constructor if it is not made then default constructor is called
but you called constructor and don’t made it
so that’s why it is giving error