0

How to add without using main function in c++

26th Oct 2016, 4:06 PM
Arbaaz Khan
Arbaaz Khan - avatar
3 odpowiedzi
+ 2
Your program must have a main function. It is the function that is executed when launching your program.
26th Oct 2016, 4:40 PM
Zen
Zen - avatar
+ 1
As @Zen said definitely we need the main() method to execute our program. But still you can do the addition of two numbers before main gets called. Like this, class test { test () { cout << 4 + 5 << endl; } }; test obj; int main () { cout << "Inside Main"; return 0; } OUTPUT for this is : 9 Inside Main obj gets create before main gets called because global object will be created or initialize before main gets called. Hope this is what you are looking for and I guess it's helpful to you.
26th Oct 2016, 4:50 PM
Venkatesh(Venki)
Venkatesh(Venki) - avatar
0
create a seperate function with a return value
27th Oct 2016, 2:39 AM
Null Void
Null Void - avatar