U E D R , A S I H C RSS

cpp스터디인데이름을못짓겠어요/7월14일 (rev. 1.1)

cpp스터디인데이름을못짓겠어요/7월14일

#include<iostream>
using namespace std;

class AAA{
private:
	int num;
public:
	AAA() : num(0){};

	AAA &CreateInitObject(int n) const//n값 안변함 보장
	{
		AAA *gms = new AAA(n);
		return *gms;
	}
	void const Shownum()
	{
		cout << num << endl;
	}
private:
	AAA(int a){
		num = a;
	}
};

int main(){
	AAA base;
	base.Shownum();
	AAA &obj1 = base.CreateInitObject(3);
	obj1.Shownum();
	delete &obj1;

	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:40
Processing time 0.0160 sec