title: String declaration in managed c++
body: <p>I am trying to declare an string variable in a c++/CLI app .</p>
  
  <p>My declaration looks like :</p>
  
  <p><code>String^ strRptPath = "C:\Reports\NorthwindCustomers.rpt";
  </code></p>
  
  <p>and i have this errors :</p>
  
  <p><code>error C2059: syntax error : '^'</p>
  
  <p>error C2238: unexpected token(s) preceding ';'
  </code></p>
  
  <p>I have also tried this method :</p>
  
  <p><code>String^ strRptPath =gcnew String("C:\Reports\NorthwindCustomers.rpt");</code> </p>
  
  <p>it returns the same errors .</p>
  
  <p>The entire code is :</p>
  
  <pre><code>   #pragma once
  namespace CRViewerXI
  {
      using namespace System;
      using namespace System::Text;
      using namespace System::ComponentModel;
      using namespace System::Collections;
      using namespace System::Windows::Forms;
      using namespace System::Data;
      using namespace System::Drawing;
      using namespace CrystalDecisions::Windows::Forms;
  
  public __gc class Form1 : public System::Windows::Forms::Form
  {   
  public:
      Form1(void)
      {
          InitializeComponent();
      }
  
  
  protected:
      void Dispose(Boolean disposing)
      {
          if (disposing &amp;&amp; components)
          {
              components-&gt;Dispose();
          }
          __super::Dispose(disposing);
      }
  
  private:
      CrystalDecisions::Windows::Forms::CrystalReportViewer *CRViewer;
      System::ComponentModel::Container * components;
  
  
  private : String^ strRptPath =gcnew String("C:\\Reports\\NorthwindCustomers.rpt");
      void LoadReport()
      {
  
      }
  
  
      void InitializeComponent(void)
      {
          CRViewer = new CrystalDecisions::Windows::Forms::CrystalReportViewer();
          CRViewer-&gt;ActiveViewIndex = -1;
          CRViewer-&gt;ShowGroupTreeButton = true;
          CRViewer-&gt;ShowExportButton = true;
          CRViewer-&gt;EnableToolTips = true;
          CRViewer-&gt;DisplayToolbar = true;
          CRViewer-&gt;Dock = System::Windows::Forms::DockStyle::Fill;
          Controls-&gt;Add(CRViewer);
  
          this-&gt;AutoScaleBaseSize = System::Drawing::Size(5, 13);
          this-&gt;ClientSize = System::Drawing::Size(528, 394);
          this-&gt;Name = S"Form1";
          this-&gt;Text = S"Form1";
          this-&gt;Load += new System::EventHandler(this, Form1_Load);
  
      }   
  private: System::Void Form1_Load(System::Object *  sender, System::EventArgs *  e)
          {   
  
  
          }
  
  };
  </code></pre>
  
  <p>}</p>
  
  <p>Am i doing somthing wrong ?
  It is my first time working in managed c++.</p>
  
  <p>Thanks.</p>