본문 바로가기

카테고리 없음

copy constructor

#include "stdafx.h"

#include <iostream>

#include <string>


using namespace std;


class People {

private:

const string name;

int age;


public:

People(const string &name) 

: name(name), age(19)

{

cout << "Constructor!" << endl;

}


void PrintName(void)

{

cout << name << endl;


return;

}

};


class WhatYourName {

private:

People me;


public:

WhatYourName()

: me("Aumoa")

{


}

int Run();

};


int main() {


WhatYourName program;


return program.Run();

}


int WhatYourName::Run() {

me.PrintName();

return 0;

}