GithubHelp home page GithubHelp logo

modern-cpp's Introduction

modern-CPP



어려운 부분, 헷갈리는 부분들을 모아두었습니다.



strlen & sizeof


strlen은 할당받은 문자열의 길이....NULL을 제외함 sizeof는 데이터가 할당받은 메모리 바이트의 길이

new 와 delete


new와 delete는 모두 C++의 기본 연산자이다.
delete는 동적으로 배열을 생성한 경우 사용이 가능하다.
Cube *c = new Cube[4];
delete [] c;

call by value VS call by reference VS call by address


value : 값을 그대로 복사하므로 따로 메모리를 할당한다. reference : & address : *

얕은 복사와 깊은 복사


얕은 복사는 주소를 공유하지만 깊은 복사는 주소를 공유하지 않음(자원을 공유하지 않음) 주소, 메모리를 공유하게 되면 소멸자를 실행할 때 먼저 하나가 소멸되면 이전에 만들어졌던 객체가 같은 메모리를 또 소멸시킨다....이 때 오류 발생. 동적 할당 시에는 무조건 깊은 복사를 써야 함!!!

const 키워드


일반 변수에서의 const


변수를 상수화함. const로 정의한 변수는 재정의할 수 없다!!
const int x = 4;
// 이렇게 할 수 없다는 말씀~!
x = 10;

포인터 변수에서의 const


class를 나타내는 변수 앞에 작성된다. class 내 멤버 변수를 모두 복사해야 한다!

this와 *this의 차이점


this는 자기 자신을 가르키고 있는 포인터 개념이고

*this는 자기 자신의 클래스 그 자체라고 보시면 됩니다.

modern-cpp's People

Contributors

jordan-comlinee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.