Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anything like the c# params in c++?

Tags:

That is the question.

like image 878
devoured elysium Avatar asked Jul 20 '09 20:07

devoured elysium


People also ask

Does Russia have anything like the AC-130?

The upgraded variant An-12BP became the standard tactical transport of the Soviet and other air forces. In 2019, it was announced at the military "Army-2019" Forum that Russia started working on an armed ground-attack and close air support variant of the An-12, similar to the AC-130.

Is the AC-130 real?

The Lockheed AC-130 gunship is a heavily armed, long-endurance, ground-attack variant of the C-130 Hercules transport, fixed-wing aircraft. It carries a wide array of ground-attack weapons that are integrated with sophisticated sensors, navigation, and fire-control systems.

What is the AC-130 armed with?

The AC-130 is armed with a fearsome array of weaponry, including a 105 mm cannon and 25 or 40 mm gatling guns. The AC-130U employs a synthetic aperture strike radar for long-range and adverse weather target detection and identification.


2 Answers

Yes. In standard C++, you can use va_arg and the ... syntax. See MSDN for details.

For C++/CLI, There is a shortcut for this.

You do this as:

void TheMethod( String^ firstArgument, ... array<Object^>^ variableArgs ); 

See this blog post for details.

like image 165
Reed Copsey Avatar answered Oct 11 '22 23:10

Reed Copsey


For unmanaged C++ with the same convenient syntax, no.

But there is support for variable argument lists to functions in C++.

Basically you declare a function with the last parameter being an ellipsis (...), and within the body of the function use the va_start()/va_arg() calls to parse out the supplied parameter list.

This mechanism is not type safe, and the caller could pass anything, so you should clearly document the public interface of the function and what you expect to be passed in.

For managed C++ code, see Reed's comments.

like image 23
LBushkin Avatar answered Oct 11 '22 22:10

LBushkin