U E D R , A S I H C RSS

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

#include<iostream>
#include<cstdlib>
using namespace std;

class Simple{
public:
	Simple(){
		cout << "I'm a constructor!" << endl;
	}
};

int main()
{
	cout << "Case 1 : ";
	Simple * sp1 = new Simple;
	cout << "Case 2 : ";
	Simple*sp2 = (Simple*)malloc(sizeof(Simple) * 1);
	cout << endl << "end of main" << endl;
	delete sp1;
	free(sp2);
	return 0;
}

#include<iostream>
using namespace std;

int& RefRetFuncOne(int &ref)//참조자. 별명
{
	ref++;
	return ref;
}

int main(void){
	int num1 = 1;
	int &num2 = RefRetFuncOne(num1);
	num1++;
	num2++;
	cout << "num1 : " << num1 << endl;
	cout << "num2 : " << num2 << endl;
	return 0;
}

#include<iostream>
using namespace std;

int& RefRetFuncOne(int &ref)//참조자. 별명
{
	ref++;
	return ref;
}

int main(void){
	int num1 = 1;
	int num2 = RefRetFuncOne(num1);
	num1+=1;
	num2+=100;
	cout << "num1 : " << num1 << endl;
	cout << "num2 : " << num2 << endl;
	return 0;
}

#include<iostream>
using namespace std;

int RefRetFuncOne(int &ref)//참조자. 별명
{
	ref++;
	return ref;
}

int main(void){
	int num1 = 1;
	int num2 = RefRetFuncOne(num1);
	num1+=1;
	num2+=100;
	cout << "num1 : " << num1 << endl;
	cout << "num2 : " << num2 << endl;
	return 0;
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:38
Processing time 0.0068 sec