목록C, C++ (23)
Typing diary
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#include #include #include using namespace std; class Random{public: Random(); int next(); int nextInRange(int fir,int sec);}; int main(void){ Random r; cout
12345678910111213141516171819#include using namespace std; class exc{public: exc() {} // 기본 생상자를 만들어 주자 exc(int a) {}}; int main(){ exc a[10]; //객체 배열 선언문은 반드시 기본 생성자를 호출한다! //exc c[10](3); ->구문 오류 exc b[3] = { exc(1), exc(2), exc() }; // 객체 배열 초기화 } Colored by Color Scriptercs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #include #include //malloc , free함수 사용을 위한 헤더 파일 int main() { //※ C 메모리 동적 할당 //malloc(size) : size바이트 수 만큼 할당하고 (void*)형으로 위치 반환. //free(a); 동적으로 생성된 a의 공간을 반환 int *p; // malloc에서 반환한 주소를 담을 포인터 p = (int*)malloc(sizeof(int)); // malloc은 (void*)형을 반환하므로 형변환을 해주어야 한다! if (p == NULL) // 메모리 할당 함수는 원하는 크기의 공간을 할당하지 못하면 NULL을..