본문 바로가기

복사생성자 #include #include using namespace std; class data{ private: char value[100]; public: data(char *val){ //생성자는 char* 자료형만 받는다. strcpy(value,val); //하지만 메인에서 data b를 선언하는곳을 보면 } void output(){ cout 더보기
포인터 변수와 주소 음 위에보면 kk의 처음 주소가 00396018인데 나중에 새로운 포인터 k2의 주소를 물렸을때는 주소가 00396308로 바뀐걸 볼 수 있다 더보기
c++ string 함수 구현 #include using namespace std; int mystrlen(const char *pstring); int mystrcpy(char *pdev,const char *psrc); int mystrcat(char *pdev,const char *psrc); int mystrcmp(char *pdev,const char *psrc); int main(void) { char a[10]="aaa"; cout 더보기
동적할당된 다중(이중) 포인터를 인자로 함수 호출 #include using namespace std; void set_data(int **a,int x,int y); void get_data(int **a,int x,int y); void main() { int **a=NULL; int x=0; int y=0; coutx; couty; a = new int *[x]; for(int i=0;i 더보기
이중포인터 동적할당?!? #include #include using namespace std; int main(void) { char temp[21]={0}; //이름을 입력받을 변수, 따로 변수를 만든 이유는 이름을 입력받아야 이름 크기만큼 할당 할 수 있으니까; char **stuName=NULL; //이중 포인터로 학생 이름을 저장할 변수 선언 int str_len=0; int stuCnt = 0; //학생 수(물론 학생수는 입력하는 사람의 선택에 따라 그 수가 변경됨 coutstuCnt; stuName = new char* [stuCnt];; //이중 포인터로 학생 이름을 저장할 변수 선언 for(int i=0;i 더보기
c++ 연산자,자료형 1. 연산자 우선순위 연산자 설명 결합법칙 1 :: 범위 확인 (C++만) 왼쪽에서 오른쪽 2 ++ 접미사 증가 -- 접미사 감소 () 함수 호출 [] 배열 첨자 . 참조에 의한 요소 선택 -> 포인터를 통해 요소 선택 typeid() 런타임 형식 정보 (C++만) const_cast 자료형 캐스트 (C++만) dynamic_cast 자료형 캐스트 (C++만) reinterpret_cast 자료형 캐스트 (C++만) static_cast 자료형 캐스트 (C++만) 3 ++ 접두사 증가 오른쪽에서 왼쪽 -- 접두사 감소 + 단항 덧셈 - 단항 뺄셈 ! 논리적 NOT ~ 논리적 비트 NOT (자료형) 자료형 캐스트 * 우회 (역참조) & 의-주소 sizeof 의-크기 new, new[] 동적 메모리 할당 (.. 더보기