How many ways can a function (called) be called in C ++?

I know one way to call a function:

func(x, y);

Is it still possible to call a function call?

+4
source share
4 answers

You can call functions

  • explicitly by providing the argument bracket after the function designation (in the case of constructors, this is clearly not formally the correct formulation, since they have no names, but in any case),

  • implicitly, in particular destructors and default constructors, but also implicit type conversion,

  • through operators other than a function call operator (), in particular a copy assignment =operator and a dereference operator ->,

  • new, , new ( , ).

, , , .

, , . , , , " ++", . , , .

+4

++ - , , 100 " ", , .

, - , - . "" :

  • , /
  • ( ) ( "" ).
  • "" , .

, .

, 100%, , ++ .

class MyClass{
 public:
 void myFunction(int A);
}

, .

, :

myObject.myFunction(A) 
is in a way equivalent to calling:
myFunction(myObject,A)

, .

, :

  • myFunc (a, b);
  • . typedef int (* funcP) (int, in);
  • . overload () .
  • ++ 11 std:: function , ,
  • - .
  • .
  • , , callback
  • . (, boost.signals2 Qt )
  • DLL . DLL-
  • . rpc.

, .

, , RTTI. , , #. , . . - Qt MOC.

+1

:

  • f(arguments...)

  • ( -)

  • std::function - ( , ​​, , - , )

:

  • , , static/global thread-specific new,

  • , , delete d, , , ala x.~X()

  • ([], +=, ==, < ..)

, , :

  • - std::atexit() std::at_quick_exit(), std::terminate,

  • ( , , )

:

  • main()

  • std::unexpected, std::unexpected_handler, std::terminate

setjmp longjmp "" ... , .

"++", , .

+1

? , foo, :

foo.func(x, y);

foo,

foo->func(x, y);

, foo, foo

bar::bar(const int x, const int y) : foo(x, y) {}

- .

0

All Articles