본문 바로가기

정규 강의/Object-Oriented Data Structures in C++

C++ Copy Constructor

source: https://www.tutorialspoint.com/cplusplus/cpp_copy_constructor.htm

 

Definition

 

The copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously. The copy cconstructor is uesed to 

 

initialize one object from another of the same type

copy an object to pass it as an argument to a functino

copy an object to return it from a function

 

+

 

A copy structor is defined implicitly by the compiler if not by programer

 

 

How it looks

 

classname (const classname &obj) {
	// body
}

 

'정규 강의 > Object-Oriented Data Structures in C++' 카테고리의 다른 글

C++ Copy Assignment Operator  (0) 2019.10.03
C++ Class Destructors  (1) 2019.10.03
C++ Pointers  (0) 2019.10.01
1.2 C++ Classes  (1) 2019.09.26