There is a class. Here is his headline:

namespace FlightController { public ref class FlightController { public: FlightController(); }; } 

At my request, the studio itself added a constructor in .cpp of the following form:

 #include "FlightController.h" FlightController::FlightController::FlightController() { throw gcnew System::NotImplementedException(); } 

I am confused by this:

 FlightController::FlightController::FlightController() 

If I add to the .cpp file using namespace FlightController; , the compiler gives an error:

FlightController ambiguous character

Is it possible to get rid of the need for a source code file to write namespace::Класс::Метод ? Is it possible to reduce this to Метод or Класс::Метод ?

  • when you добавляю using namespace FlightController; cleaned part of neymspeysa? - Grundy
  • @Grundy, which part of the namespace? Not understood. The error occurs on the description of the constructor, and not on the line using namespace - iRumba
  • I meant when you add using namespace FlightController; leave: FlightController::FlightController::FlightController() or FlightController::FlightController() - Grundy
  • @iRumba Curious, why did you decide to do C ++ / CLI? - Vlad from Moscow
  • @VladfromMoscow, because it requires study :) In fact, there was no conversation about the CLR, it’s just an evil teacher who forced me to write a project on the pros, and not choose the language myself. :) - iRumba

2 answers 2

Try writing this:

 namespace FlightController { FlightController::FlightController() { ... } // остальные методы } 

When you write using namespace FlightController , you have an external FlightController can have both a namespace and a class . In the case when you are inside the namespace FlightController , the first option disappears - except for the case when inside the namespace FlightController is another nested namespace FlightController !

    To avoid this ambiguity, add a couple more colons for "complete happiness." :) For example

     ::FlightController::FlightController::FlightController() ^^^ 

    Then the search for names begins with a global namespace.

    Of course, you would make your life easier if you didn't use the same name for the namespace and class. This is the easiest solution.