Giter Club home page Giter Club logo

programming's Introduction

πŸŽ“ Modern C++

πŸŽ“ C++의 μ£Όμš” νŠΉμ§•

  • λ©€ν‹°ν…ŒμŠ€ν‚Ή ν™•μž₯, λŸ°νƒ€μž„ μ„±λŠ₯ ν–₯상, μ™„μ „ν•œ μƒˆλ‘œμš΄ κΈ°λŠ₯
  • λŸ°νƒ€μž„ μ„±λŠ₯ ν–₯상: λ¨Έν‹°νƒœμŠ€ν‚Ή λ©”λͺ¨λ¦¬ λͺ¨λΈ, 가변인μž₯ λ“± 문법 제곡, λ©”λͺ¨λ¦¬μ™€ 계산속도 μ΅œμ ν™”
  • std:tr1 namespace lib std included
  • C++14: C++11 버그 μˆ˜μ • μ•½κ°„ 계정
  • C++ 자체 ν‘œμ€€ ν‘œμ€€ 라이브러리 포함 STL(Standard Template Library) 포함
  • βœ‹ ADT: 객체 속성 κΈ°λŠ₯ λ„μΆœ κ³Όμ •μ˜ λͺ¨λΈλ§ 좔상화 섀계 단계 Abstract Data Type C++ header file μ‚°μΆœλ¬Ό

πŸŽ“ Namespace

  • using namespace std

namespace λ„€μž„μŠ€νŽ˜μ΄μŠ€λͺ…
{
   μ„ μ–Έλ‚΄μš©; (클래슀, ν•¨μˆ˜, λ³€μˆ˜ 등을 μ •μ˜)
}

#include 
using namespace std;
namespace first {
    int value =1;
}
namespace second {
    int value =2;
}
int main() {
    cout << first::value;
    cout << sencond::value;
}
  • μžλ£Œν˜• 별칭 λ§Œλ“€κΈ°
    • using [별칭] = [κΈ°μ‘΄μžλ£Œν˜•]
      • using block = double;

int main() {
    using block = double;
    using chain = int;
      
    block eos = 123.40;
    chain ether = 678;
       
}
  • autoν˜• λ³€μˆ˜: μ΄ˆκΈ°κ°’ ν•„μš”
    • auto λ³€μˆ˜λͺ… = μ΄ˆκΈ°κ°’(μƒμˆ˜ λ³€μˆ˜ ν•¨μˆ˜ λͺ¨λ‘ κ°€λŠ₯)
  • decltypeν˜•: μ΄ˆκΈ°κ°’ λΆˆν•„μš”
    • decltype(ν•¨μˆ˜f())[μ„ μ–Έν•  λ³€μˆ˜]
    • decltype(λ³€μˆ˜)[μ„ μ–Έν•  λ³€μˆ˜]
    • decltype((λ³€μˆ˜))[μ„ μ–Έν•  λ³€μˆ˜]

πŸŽ“ 인라인 ν•¨μˆ˜

  • 일반 ν•¨μˆ˜: λ©”λͺ¨λ¦¬μƒ 점프, λ³΅μž‘ν•œ κ³Όμ •
  • 인라인 ν•¨μˆ˜: λ‹¨μˆœ κ³Όμ • λŒ€μ²΄, ν•¨μˆ˜ μ •μ˜λΆ€κ°€ μ‹€ν–‰μ½”λ“œ λŒ€μ²΄ν•˜μ—¬ μ‹€ν–‰ 속도 빠름, 단점은 ν•¨μˆ˜ μ •μ˜λΆ€κ°€ κΈΈλ©΄ λ³„λ‘œ...

inline λ°˜ν™˜ν˜• ν•¨μˆ˜λͺ…(λ§€κ°œλ³€μˆ˜ λͺ©λ‘);
  • ex)

#include
using namespace std;

class Jacob
{
  void Eat(int SteakWeight);
  inline void EatInline(int SteakWeight);
};

int main(void) {
  Jacob jacob;
  jacob.Eat(500);
  jacob.EatInline(500);
  return 0;
}

void Jacob::Eat(int SteakWeight)
{
  cout << "Eat()::Jacob is " << SteakWeight << "eat g steak" << endl;  
}

inline void Jacob::EatInline(int SteakWeight) {
  cout << "EatInline()::Jacob " << SteakWeight << "eat g steak" << endl;
}

πŸŽ“ λžŒλ‹€ ν•¨μˆ˜

  • lamda ν•¨μˆ˜: 인라인 ν•¨μˆ˜ like, also 가독성, C++11이상 λΆ€ν„° μ‚¬μš© κ°€λŠ₯
  • [] [=] [&]

#include 
using namespace std;

Class Jacob {
  public:
    void eat(int steakWeight);
    inline void eatInline(int steakWeght) {
      cout << "eatInline()::Jacob is" << steakWeight << "g steak" << endl;
    }   
};

int main(void)
{
  Jacob jacob;
  jacob.eat(1000);
  jacob.eatInline(1000);
  [](int steakWeight){cout << "eatLamda()::Jacob is eating" << steakWeight << "g steak" << endl;}(1000);
  return 0;
}

void Jacob::eat(int steakWeight){
  cout << "eat()::Jacob eat " << steakWeight << "g steak" << endl;
}

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.