C++ Compiler Error C2280 “attempting to reference a deleted function” in Visual Studio 2013 and 2015

后端 未结 7 966
误落风尘
误落风尘 2020-11-27 18:03

This snippet is compiled without errors in Visual Studio 2013 (Version 12.0.31101.00 Update 4)

class A
{
public:
   A(){}
   A(A &&){}
};

int main(i         


        
相关标签:
7条回答
  • 2020-11-27 19:08

    I faced this issue today and mine was caused by having both std::stringstream and std::ostream as member variables. I initially thought this was caused becasue I accidentally named one of them as sstream which was the name for header file I had included previously.
    But chnagng the name didnt help, and I had to remove the ostream variable completely for this to work again! then I realized I had declared it incorrectly like this :

    std::ostream some_stream;
    

    while it should have been :

    ...
    std::ostream some_stream(&filebuf);
    

    basically I was much better off using ofstream instead!

    0 讨论(0)
提交回复
热议问题