Programming/C++ STL2023. 2. 9. 11:31

cpp랑은 안친하다 보니.. 그나저나 템플릿을 저런식으로도 쓰나 싶긴 한데..

 

static_cast, dynamic_cast, reinterpret_cast, const_cast

[링크 : https://blockdmask.tistory.com/236]

[링크 : https://hwan-shell.tistory.com/211]

 

표준 C++에서는 변환의 안전성을 보장하기 위해 런타임 형식 검사가 수행되지 않습니다. C++/CX에서는 컴파일 시간 및 런타임 검사가 수행됩니다. 

[링크 : https://learn.microsoft.com/ko-kr/cpp/cpp/static-cast-operator?view=msvc-170]

 

캐스트 연산자에는 C++ 언어 전용 연산자가 몇 가지 있습니다. 이 연산자는 예전 스타일의 C 언어 캐스트에 있는 일부 모호함과 위험성을 제거하는 데 목적이 있습니다. 그 종류는 다음과 같습니다.
  • Dynamic_cast 다형 형식의 변환에 사용됩니다.
  • Static_cast 비포형 형식의 변환에 사용됩니다.
  • const_cast , volatile __unaligned 특성을 제거하는 const데 사용됩니다.
  • reinterpret_cast 비트의 간단한 재해석에 사용됩니다.
  • safe_cast C++/CLI에서 확인 가능한 MSIL을 생성하는 데 사용됩니다.

[링크 : https://learn.microsoft.com/ko-kr/cpp/cpp/casting-operators?view=msvc-170]

'Programming > C++ STL' 카테고리의 다른 글

::open()  (0) 2021.11.10
vector 값 비우기  (0) 2021.10.02
cpp 부모타입으로 업 캐스팅 된 객체의 원래 클래스 알기  (0) 2021.09.30
cpp string 관련  (0) 2019.06.10
cpp stringstream << 연산자  (0) 2019.05.24
Posted by 구차니
Programming/C++ STL2021. 11. 10. 18:10

QT에서 QSeialPort.open() 이 있고

QSerialPort를 상속받은 클래스에서

open()을 하면 자동으로 부모인 QSeialPort.open() 를 호출하게 되는데

CPP가 아닌 C의 fnctl.h의 open()을 열고 싶으면

::open()을 하면 되...나?

 

[링크 : https://stackoverflow.com/questions/10772169/calling-same-name-function]

'Programming > C++ STL' 카테고리의 다른 글

cpp static_cast<type>  (0) 2023.02.09
vector 값 비우기  (0) 2021.10.02
cpp 부모타입으로 업 캐스팅 된 객체의 원래 클래스 알기  (0) 2021.09.30
cpp string 관련  (0) 2019.06.10
cpp stringstream << 연산자  (0) 2019.05.24
Posted by 구차니
Programming/C++ STL2021. 10. 2. 23:17

아래의 함수가 가장 눈에 잘 들어 오는 듯?

fill(vec.begin(), vec.end(), value);

 

[링크 : https://hini7.tistory.com/66]

'Programming > C++ STL' 카테고리의 다른 글

cpp static_cast<type>  (0) 2023.02.09
::open()  (0) 2021.11.10
cpp 부모타입으로 업 캐스팅 된 객체의 원래 클래스 알기  (0) 2021.09.30
cpp string 관련  (0) 2019.06.10
cpp stringstream << 연산자  (0) 2019.05.24
Posted by 구차니
Programming/C++ STL2021. 9. 30. 14:58

dynamic_cast<>() 를 통해 변환해보면 원래 타입을 알 수 있음.

[링크 : https://stackoverflow.com/questions/307765/how-do-i-check-if-an-objects-type-is-a-particular-subclass-in-c]

 

+

해보니 완벽하게 탐지하지는 못하는 듯..

'Programming > C++ STL' 카테고리의 다른 글

::open()  (0) 2021.11.10
vector 값 비우기  (0) 2021.10.02
cpp string 관련  (0) 2019.06.10
cpp stringstream << 연산자  (0) 2019.05.24
c++ 함수 인자 기본값  (0) 2017.11.08
Posted by 구차니
Programming/C++ STL2019. 6. 10. 19:01

파싱, tokenizer

[링크 :https://psychoria.tistory.com/666]

[링크 : https://stackoverflow.com/questions/53849/how-do-i-tokenize-a-string-in-c]

 

string을 숫자로

[링크 : http://yotop93.blogspot.com/2015/04/string.html]

 

문자열 자르기

-1 식으로 끝에서 자르는건 안되는 듯

[링크 : http://www.cplusplus.com/reference/string/string/substr/]

'Programming > C++ STL' 카테고리의 다른 글

vector 값 비우기  (0) 2021.10.02
cpp 부모타입으로 업 캐스팅 된 객체의 원래 클래스 알기  (0) 2021.09.30
cpp stringstream << 연산자  (0) 2019.05.24
c++ 함수 인자 기본값  (0) 2017.11.08
cpp string compare 와 ==  (0) 2017.01.31
Posted by 구차니
Programming/C++ STL2019. 5. 24. 15:43

어떻게 보면.. scanf를 좀 편리하게 해주는 cpp용 연산자라고 보면 되려나?

 

[링크 : http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/]

 

string str_sensor_data(mesg);
stringstream stream(str_sensor_data);
for(int i=0;i<5;i++){

    stream >> sensor_data[i]; 

}

[링크 : http://youngmok.com/udp-server-c-class-listening-thread/]

'Programming > C++ STL' 카테고리의 다른 글

cpp 부모타입으로 업 캐스팅 된 객체의 원래 클래스 알기  (0) 2021.09.30
cpp string 관련  (0) 2019.06.10
c++ 함수 인자 기본값  (0) 2017.11.08
cpp string compare 와 ==  (0) 2017.01.31
cpp this  (0) 2016.07.18
Posted by 구차니
Programming/C++ STL2017. 11. 8. 15:59

정작 써본건 처음이라..

아무튼 이녀석은 오른쪽 부터 기본값을 정할 수 있고

값이 없으면 기본값이 들어간다.


그런데 함수 prototype에 없는거지

함수 선언에 넣으면 아래와 같이 재정의 되었다고 배를 짼다.


error C2572: 'CtestDlg::sender' : 기본 매개 변수 재정의. 매개 변수 9

'CtestDlg::sender' 선언을 참조하십시오. 


[링크 : http://shaeod.tistory.com/365]


근데 이게.. msvc 특성인지 gcc나 다른것도 포함하는 표준인지 모르겠네...

'Programming > C++ STL' 카테고리의 다른 글

cpp string 관련  (0) 2019.06.10
cpp stringstream << 연산자  (0) 2019.05.24
cpp string compare 와 ==  (0) 2017.01.31
cpp this  (0) 2016.07.18
class 기본 접근제한자  (0) 2016.07.18
Posted by 구차니
Programming/C++ STL2017. 1. 31. 09:20

cpp에서는 string 형 변수일 경우 ==를 compare로 묶어놔서

둘이 같은거다 라는건가?


[링크 : http://stackoverflow.com/questions/9158894/differences-between-c-string-and-compare]

[링크 : https://msdn.microsoft.com/ko-kr/library/windows/desktop/e4abh74z(v=vs.80).aspx]

'Programming > C++ STL' 카테고리의 다른 글

cpp stringstream << 연산자  (0) 2019.05.24
c++ 함수 인자 기본값  (0) 2017.11.08
cpp this  (0) 2016.07.18
class 기본 접근제한자  (0) 2016.07.18
cpp 매크로 __PRETTY_FUNCTION__  (0) 2016.07.18
Posted by 구차니
Programming/C++ STL2016. 7. 18. 20:57



[링크 : http://www.learncpp.com/cpp-tutorial/8-8-the-hidden-this-pointer/]


문득 this를 쓰면 잘못된게 아닐까? 라는 생각

문법으로도 지원하는 자기자신을 의미하지만

크게 쓸 의미도 없고 (명시적으로 표기한다면야 머...)

굳이 명시적으로 써야할 멤버 함수 인자의 명칭과 클래스 멤버 변수가 충돌할경우?


[링크 : http://stackoverflow.com/questions/6779645/use-of-this-keyword-in-c]

[링크 : http://stackoverflow.com/questions/2337540/when-should-you-use-the-this-keyword-in-c]

'Programming > C++ STL' 카테고리의 다른 글

c++ 함수 인자 기본값  (0) 2017.11.08
cpp string compare 와 ==  (0) 2017.01.31
class 기본 접근제한자  (0) 2016.07.18
cpp 매크로 __PRETTY_FUNCTION__  (0) 2016.07.18
cpp dlopen / gcc -l  (0) 2016.07.12
Posted by 구차니
Programming/C++ STL2016. 7. 18. 17:47

말은 거창한데..


결론

class 내에 기본적으로 모든 유형에 대해서 

private:로 설정됨


[링크 : http://www.cplusplus.com/doc/tutorial/classes/]



근데 이런것도 정리 안해놧었나 -ㅁ-?!?!??

'Programming > C++ STL' 카테고리의 다른 글

cpp string compare 와 ==  (0) 2017.01.31
cpp this  (0) 2016.07.18
cpp 매크로 __PRETTY_FUNCTION__  (0) 2016.07.18
cpp dlopen / gcc -l  (0) 2016.07.12
cpp thread.... / pthread  (0) 2016.07.11
Posted by 구차니