0

I'm updating a VS2010 C++ application to VS2012 and I'm getting the error

cannot access private member declared in class 'CObject'

This appears to be due to the complier generated function

CObArray::CObArray(const CObArray &).

Is there a way I can disable the compile generated functions? Or a way of knowing why it's creating the functions?

Cœur
  • 37,241
  • 25
  • 195
  • 267
pcowan
  • 39
  • 3
  • `This appears to be due to the complier generated function` Why do you think so? – cpplearner Dec 24 '15 at 14:42
  • Because the compiler output says "This diagnostic occurred in the compiler generated function 'CObArray::CObArray(const CObArray &)'" – pcowan Dec 24 '15 at 14:45
  • 2
    Don't try to copy your objects? – n. m. could be an AI Dec 24 '15 at 15:14
  • There is a Copy() function that is supposed to be used instead of the copy constructor which is private. https://msdn.microsoft.com/en-us/library/f24tx153.aspx – drescherjm Dec 24 '15 at 15:16
  • 1
    You have an error in the code that you haven't shown. – Pete Becker Dec 24 '15 at 15:18
  • 1
    Do you already understand how compiler generated functions work in general and believe there's a specific reason why the copy constructor shouldn't be generated in this case? – Kyle Strand Dec 24 '15 at 15:18
  • 1
    This is very intentional for the CObject class, it has its copy constructor and assignment operator declared *private*. In modern C++ they would have been declared `= delete`. You must likewise ensure that your CObject-derived class cannot be copied. – Hans Passant Dec 24 '15 at 16:19
  • Thanks for the comments, however they do not address my question: "Is there a way I can disable the compiler generated functions?" – pcowan Dec 26 '15 at 14:38
  • Yes, I understand how compiler generated functions work, but they are causing the error. It's a huge application and I know somewhere in the code there is an object being copied when it shouldn't be, I need to find out where this copy is occurring so I can fix this code. – pcowan Dec 26 '15 at 14:46

0 Answers0