본문 바로가기

카테고리 없음

reference variation

#include "stdafx.h"

#include <iostream>

#include <string>


int main() {

using namespace std;


int num = 0;

int &ref = num; //선언과 동시에 초기화!


cout << num << ", " << ref << endl;


num += 1;


cout << num << ", " << ref << endl;


ref += 1;


cout << num << ", " << ref << endl;


return 0;

}