집에와서 해보니, BIOS 에서 부터 Shift를 누르는것은 들어가지지 않고,
BIOS 에서 Bootloader로 넘어가는 시점에서 부터 Shift 키를 누르고 있어야 GRUB loader menu로 진입하였다.
눌렀다 뗐다 하는것도 안되고, 계속 메뉴가 뜰때까지 누르고 있어야 하는데 음.. 이건 촘 아니라는 느낌..
update-grub2를 실행해보니, /boot에 추가된 파일을 찾아 자동으로 전부 추가하는 것으로 추측된다.
$ sudo update-grub2
[sudo] password for morpheuz:
Generating grub.cfg ...
Found background image: moreblue-orbit-grub.png
Found linux image: /boot/vmlinuz-2.6.32.15+drm33.5
Found linux image: /boot/vmlinuz-2.6.32-24-generic
Found initrd image: /boot/initrd.img-2.6.32-24-generic
Found linux image: /boot/vmlinuz-2.6.32-23-generic
Found initrd image: /boot/initrd.img-2.6.32-23-generic
Found linux image: /boot/vmlinuz-2.6.32-22-generic
Found initrd image: /boot/initrd.img-2.6.32-22-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found memtest86+ image: /boot/memtest86+.bin
done
int& a;
요 &가 바로 레퍼런스 변수이다.
어떻게 보면 포인터와 비슷하지만, 다른 녀석이고, C++ 공부중에 함수 인자에서 혼동을 느끼게 한 녀석이다.
// more than one returning value
#include <iostream>
using namespace std;
void prevnext (int x, int& prev, int& next)
{
prev = x-1;
next = x+1;
}
int main ()
{
int x=100, y, z;
prevnext (x, y, z);
cout << "Previous=" << y << ", Next=" << z;
return 0;
}
위의 소스중, prevent() 함수의 두/세번째 인자가 바로 reference 변수인데,
C에서는 당연히 포인터로 넘겨주어야 할꺼라고 생각을 했는데,
C++에서는 변수를 그냥 인자로 취해줌에도 불구하고 원본의 값이 바뀐다.
(당연히.. 레퍼런스 변수란걸 모르니 이상하게 보일수 밖에 ㅠ.ㅠ)
처음에는 자동형변환과 연관이 되어있나 했는데.. 그거랑은 거리가 좀 있는것 같고
그냥 단순히 C++ 문법적 특성으로 "참조형 변수" 라고 생각중 -_-
C++ 참조와 포인터의 차이점
- 만들어지면 값 변경불가
- 위의 이유로 null로 선언불가
C++ references differ from pointers in several essential ways:
It is not possible to refer directly to a reference object after it
is defined; any occurrence of its name refers directly to the object it
references.
Once a reference is created, it cannot be later made to reference another object; it cannot be reseated. This is often done with pointers.
References cannot be null, whereas pointers can; every reference refers to some object, although it may or may not be valid.
References cannot be uninitialized. Because it is impossible to
reinitialize a reference, they must be initialized as soon as they are
created. In particular, local and global variables must be initialized
where they are defined, and references which are data members of class
instances must be initialized in the initializer list of the class's
constructor. For example:
개인적으로는, x 값과 x의 값을 변경하는 부분을 추가하여 의문을 가지게 되었다.
위의 int x는 그 루틴을 종료하고 나서 값이 변경되지 않았지만,
아래의 int& x는 루틴종료후 x의 값이 1로 변경되었고, 즉 포인터와 같은 역활을 하는 것으로 보였다.
하지만, prevent() 함수에 들어가는 인자는 "x, y, z" 였고 포인터 값이 아님에도 불구하고 변경되었다는 점이 신기했다.
아무튼.. C와 C++은 다른거구나 라고 깨닫는중...
void prevnext (int x, int& prev, int& next)
{
prev = x-1;
next = x+1;
x = 1;
}
void prevnext (int& x, int& prev, int& next)
{
prev = x-1;
next = x+1;
x = 1;
}
x는 main() 함수이고, tt는 prevnext()내의 변수이다.
특이하게도(?) tt의 주소값이 x 변수의 주소값과 동일하다.