Compartilhar via


VCCodeFunction.AddInitializer(String) Method

Definition

Adds a C++ initializer to a constructor's member initializer list.

public:
 void AddInitializer(System::String ^ bstrText);
public:
 void AddInitializer(Platform::String ^ bstrText);
void AddInitializer(std::wstring const & bstrText);
[System.Runtime.InteropServices.DispId(586)]
public void AddInitializer (string bstrText);
[<System.Runtime.InteropServices.DispId(586)>]
abstract member AddInitializer : string -> unit
Public Sub AddInitializer (bstrText As String)

Parameters

bstrText
String

Required. The full text of the initializer.

Attributes

Examples

This example adds an initialization string to the first function, assuming that the first function has a variable m_func.

Sub AddInitializer()  
    Dim vcCM As VCCodeModel  
    Dim vcClass As VCCodeClass  
    Dim vcVariable As VCCodeVariable  
    Dim vcFunction As VCCodeFunction  
    vcCM = DTE.Solution.Item(1).CodeModel  
    vcClass = vcCM.AddClass("MyClass", "MyClass.h")  
    vcVariable = vcClass.AddVariable("m_var", "int")  
    vcFunction = vcClass.AddFunction("MyClass", vsCMFunction.vsCMFunctionConstructor, "")  
    vcFunction.AddInitializer("m_var(0)")  
End Sub  

Applies to