Interestingly, something is wrong with the copy constructor function below?
class A { private: int m; public: A(A a){m=a.m} }
Two things:
Copy constructors must accept links as parameters, otherwise they are infinitely recursive (in fact, the language will not allow you to declare such constructors)
It does nothing that the ctor copy does not do by default, but it does it poorly - you should use the initialization lists in the ctor copy where possible. And if the default ctor copy does what you want, don’t be tempted to write the version yourself - you will probably make a mistake and you will need to maintain it.
There are 3 problems.
-, ";" m = a.m, .
-, , - .
-, , . , , , :
A (const A a): m (a.m) {}
, , . , ( ), . , , . :
A(A const& a) : m(a.m) {}
Source: https://habr.com/ru/post/1736513/More articles:Line Search with Jagged Array? - c #Xcode Objective-c предупреждения "создание селектора несуществующего метода" с помощью OCUnit (SenTestingKit) - objective-cKomodo Change memory options "new team" - komodoeditDisaster file recovery on Amazon S3? - amazon-s3Starting and destroying a Singleton Single Selenium Server process for a C # DLL's lifespan - processМоно: Возможно ли разместить веб-службу/wcf-службу из консольного приложения? - linuxNew to C # and trying to use a global variable - c #Can X Connection and Streams Get along? - multithreadingLIBPATHS is not used in the Makefile, cannot find a shared object - c ++Get an instance from StructureMap by name type - c #All Articles