C++ 생성자 위임 (delegating constructor)
단순히 생성자를 생성 해 두고 생성자를 위임 함으로서 중복 코드를 막는 기능을 테스트 해보았다.
#include <string>#include <iostream>
class Test{private:
public: Test() { //runf }
Test(int A) : Test() {
}};
class Employee{private: int m_ID; std::string m_Name;
public: Employee(int id, const std::string &name) :m_ID(id),m_Name(name) { std::cout<<"Employee"<<m_Name<<"created.\n"<<std::endl; }
Employee(const std::string &name) :Employee(0,name) {
}};
int main(){
}
댓글
댓글 쓰기