c++ cli - ...array<Object^>^ args -
i'm reading c++/cli. see stuff:
object^ createinstancefromtypename(string^ type, ...array<object^>^ args) { if (!type) throw gcnew argumentnullexception("type"); type^ t = type::gettype(type); if (!t) throw gcnew argumentexception("invalid type name"); object^ obj = activator::createinstance(t, args); return obj; }
when calling it:
object^ o = createinstancefromtypename( "system.uri, system, version=2.0.0.0, " "culture=neutral, publickeytoken=b77a5c561934e089", "http://www.heege.net" );
what ...array^ args? if remove ... ,there's complied-error:
error c2665: 'createinstancefromtypename' : none of 2 overloads convert argument types 1> .\myfourthcplus.cpp(12): 'system::object ^createinstancefromtypename(system::string ^,cli::array<type> ^)' 1> 1> [ 1> type=system::object ^ 1> ] 1> while trying match argument list '(const char [86], const char [21])'
like c++, c++/cli has mechanism variable amount of arguments. ...
in front of ...array<object^>^
parameter means.
for type safety c++/cli designers added managed syntax declare type of variable array.
since it's passing parameter activator::createinstance()
function, @ variable parameters activator function looking for.
Comments
Post a Comment