c++ - For no copy classes, can I change the code so that the VS2010 compiler will flag an error on the offending line? -


Can I change the code, so that the error messages from the VS 02010 compiler can point out the offensive line of code?

  Class nokia {// & lt; - Error appears here; NoCopy (ConstaCopy & amp;;); // & lt; - And the error appears here: NoCopy & amp; Operator = (Constant Nokp & amp;;); Public: Nokia () {}; }; Structure Other Class: Nokia {}; // & lt; - and error appears here int_tmain (int argc, _TCHAR * argv []) {AnotherClass c; Other class D = C; // & lt; - But error does not appear here 0; }  

Note that 'Nokia (Constellate & amp;) = Delete;' VS2010 does not promote I do not promote.

This was added according to Mitchell's suggestion:

  1> ------ Construction started: Project: Test, Configuration: Debug Win32 - ----- 1> Test.cpp 1> C: \ Test \ Test.cpp (16): Error C2248: 'NoCopy :: NoCopy': Class 'Notebook' 1 & gt; C: \ Test \ Test.cpp (8): 'Noviper :: Notebook' 1 & gt; C: \ Test \ Test.cpp (7): 'Notebook' 1 & gt; See the announcement of this Diagnostic Compiler in the built-in function 'Other Classes: Other Classes (CONSTORE & amp);' ========= Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skip === =======  

The error was not shown on the correct line Because the visual studio does not know where it came from, which is automatically compiled another class (ContextClass End) . You have to find out where the error for the Visual Studio is obtained, it must be clearly defined to continue.

  class nonpp {nonpp (no. Nocopy & operator = (constant nocp & amp;;); public: noppy () {};}; structure other class: nopi {other class (); // Since there is another creator, which is _could_ fit, // it must also be defined as private: define it another class (Console & amp;); //}; int _tmain (int argc, _TCHAR * Argv []) {AnotherClass c; Other class D = C; // - Error now shows here 0;}  

Now you will get:

1> \ main.cpp (20): Error C2248: 'Other Slash :: Other Classes': The member class can not access the private category has been declared in 'another class'

which refers to the "right" line.

< / Div>

Comments