c++ 에서 변수 초기화를 괄호를 이용하여 다음과 같이 할 수 있다.

 

초기화 할 때만 되고, 일반적인 assign 문으로는 사용할 수 없다.

즉, 다음과 같은 문장은 에러다.

Trackback Address :: http://seirion.com/trackback/223 관련글 쓰기

댓글을 달아 주세요

  1. 참참 2012/05/14 22:27 Address Modify/Delete Reply

    이런게 가능했었군요... ㅎㅎ

  2. |꼬마늑대| 2012/05/15 21:42 Address Modify/Delete Reply

    클래스 초기화와 유사한 원리

singleton pattern

프로그래밍 2012/05/12 11:16 |

singleton pattern 이란 대략 평생 하나의 instance 만 만들겠다는 것.

대략 constructor 를 private 으로 두어 외부에서는 instance 를 생성하지 못 하게 하고,

하나의 경로로만 instance 를 받게 하는 방식이다.

 

이 코드의 예에서는 외부에서 Babo::getInstance() 함수를 통해서 클래스의 instance 를 받을 수 있다.

그런데, 보면 결국 이 클래스의 instance 의 scope 는 전역이 된다.

즉, 어디서건 접근을 막을 수가 없다. 이렇게 해도 문제가 없을까나 ...

Trackback Address :: http://seirion.com/trackback/222 관련글 쓰기

  1. Subject: C++ 싱글톤 패턴 구현 클래스

    Tracked from 꼬마늑대의 골방 2012/05/15 22:22  Delete

    싱글톤(Singleton)은 전역에서 하나의 인스턴스에 접근하기 위해 사용하는 모델입니다. 여러가지 방법이 있고 각각의 장단점이 있지만... 저는 그 중에 Meyers singleton 방식을 주로 사용합니다. 아..

댓글을 달아 주세요

  1. |꼬마늑대| 2012/05/15 22:24 Address Modify/Delete Reply

    내가 자주 사용하는 방법 트랙백 걸어드림.


신입 사원 면접이 있으면 써 먹어 보고 싶은 것.
1 부터 100까지 더하기


 
요렇게 풀면 정석.



요렇게 풀면 뽑힐 가능성 높음.



요런 사람이 있다면 정신 세계를 좀 들여야 볼 필요가 있음.
망나니이거나 천재형이 아닐런 지 ...
 

Trackback Address :: http://seirion.com/trackback/221 관련글 쓰기

댓글을 달아 주세요

  1. |꼬마늑대| 2012/03/28 11:29 Address Modify/Delete Reply

    요렇게 푸는 사람은?
    int sum(int n)
    {
    if (n == 1)
    return 1;
    return n + sum(n-1);
    }

    printf("%d\n", sum(100));


    혹은 이렇게 푸는 사람은?
    template<int N> class num
    {
    private:
    int sum;
    public:
    num()
    { sum = (1+N)*N/2; }
    void print(void)
    { printf("%d\n", sum); }
    };

    num<100> sum;
    sum.print();


    뽑아주나?

    그리고
    문제가 "1부터 100까지 더하는 코드를 작성하시오."였다면 2번과 3번 다 오답.
    문제가 "1부터 100까지 더한 결과를 출력하시오."였다면 전부 정답.
    하지만 문제를 "1부터 n까지 더한 결과를 출력하시오."로 바꾼다면 더 적절할듯.

    • 바보세룐 2012/03/28 16:40 Address Modify/Delete

      recursion 사용했다면 뽑을 수 있겠지만,
      template 쓴 사람은 사상을 의심해 볼 거 같아요.

  2. 바보세룐 2012/03/28 16:41 Address Modify/Delete Reply

    대졸자에게 이건 너무 쉬운 문제일까나 ...
    100 말고 n 까지 더해서 결과 return 하는 함수 정도를 만들 게 하는 게 적절할 듯.



일단 대략 CButton 클래스를 서브 클래싱 해서 ImageButton 을 만들었다.
왼쪽 버튼을 누를 때와 뗄 때를 오버라이딩 했다.

보통 하듯이 버튼을 누를 때 SetCapture() 해 두고,
버튼을 뗄 때 ReleaseCapture() 해서 잡고 있던 걸 해제 하도록 만들었다.

그런데,
이렇게 하고 나니 버튼 이벤트를 처리하기 위한 WM_COMMAND 가 parent 로 날아오지 않는다.


한참 삽질 한 뒤에 ReleaseCapture() 구문을 주석처리 하고 나니 정상적으로 이벤트가 날아 온다 ㅠㅠ

어찌된 영문인 지 아직 모르겠다.
아시는 분 좀 알려주시오 ㅠㅠㅠㅠㅠㅠㅠ

Trackback Address :: http://seirion.com/trackback/215 관련글 쓰기

댓글을 달아 주세요

android.widget.TextView 에서 setTextSize() method 를 보면,
파라미터가 scaled pixel 이라고 되어 있다.

조심해서 쓰자 -_-;

단위까지 표현하고 싶다면 파라미터 2개짜리 method 를 사용하면 된다.

public void setTextSize (float size)

Since: API Level 1

Set the default text size to the given value, interpreted as "scaled pixel" units. This size is adjusted based on the current density and user font size preference.

Related XML Attributes
Parameters
size The scaled pixel size.

public void setTextSize (int unit, float size)

Since: API Level 1

Set the default text size to a given unit and value. See TypedValue for the possible dimension units.

Related XML Attributes
Parameters
unit The desired dimension unit.
size The desired size in the given units.

Trackback Address :: http://seirion.com/trackback/214 관련글 쓰기

댓글을 달아 주세요

  1. 2011/03/27 23:40 Address Modify/Delete Reply

    비밀댓글입니다

  2. |꼬마늑대| 2011/04/04 04:12 Address Modify/Delete Reply

    요즘 교수님과 같이 안드로이드 수업하는데 수업자료 만드느라 죽겠삼. ㅠㅠ

layout 관련
http://rednine.tistory.com/398?srchid=BR1http%3A%2F%2Frednine.tistory.com%2F398
http://blog.naver.com/PostView.nhn?blogId=huewu&logNo=110083649927&redirect=Dlog&widgetTypeCall=true#


맵 관련
http://gtko.springnote.com/pages/5409245

http://lomohome.com/316
http://stbaeya.com/tc/215?TSSESSIONstbaeyacomtc=22fef63e7ee321167de9fad2405c475b


multi resolution screen 지원 관련
http://www.slideshare.net/mosaicnet/-5187233
http://www.androes.com/90
http://developer.android.com/guide/practices/screens_support.html
http://developer.android.com/guide/topics/resources/available-resources.html#dimension
http://theeye.pe.kr/entry/few-tips-for-android-programmer-and-ui-designer

preferences 관련
http://rsequence.com/android_blog/node/64


맥에서 안드로이드 하기
http://weasel02.tistory.com/entry/JAVA안드로이드-개발환경-설치하기-For-MAC


xml 관련
http://genieus.tistory.com/76


Content Provider 관련
http://gtko.springnote.com/pages/5151085
http://rsequence.com/android_blog/node/69


커스텀 다이얼로그
http://blog.androgames.net/10/custom-android-dialog/


activity 를 다이얼로그처럼 쓰기
http://comxp.tistory.com/141


Geocoder and reverse Geocoder
http://pheadra.tistory.com/entry/Geocoder-and-Reverse-Geocoding


apk 파일 만들기
http://www.squarelab.net/LectureBoard/2830


Custom Android Button Style and Theme
http://blog.androgames.net/40/custom-button-style-and-theme/


폰트 관련
http://rednine.tistory.com/278


안드로이드 Intent에서 앱 호출하는 방법을 정리
http://nuninaya.tistory.com/580


Rotation and GL Overlay in Android
http://blog.graphtech.co.il/rotation-and-gl-overlay-in-android/


마켓 등록
http://blog.naver.com/PostView.nhn?blogId=drparksc&logNo=20118204397


배포용 키 & apk 등
http://roter.pe.kr/125
http://appleandroidjunhulove.tistory.com/tag/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C%20%EB%A7%88%EC%BC%93%20%EB%B0%B0%ED%8F%AC


이클립스 git 사용하기
http://hightin.tistory.com/16

Trackback Address :: http://seirion.com/trackback/211 관련글 쓰기

댓글을 달아 주세요

대략 아래와 같이 하면 됨.
만약 설정에서 GPS 를 disable 시킨 상태라면 false 가 리턴 됨.


Trackback Address :: http://seirion.com/trackback/210 관련글 쓰기

댓글을 달아 주세요

c++ 에서 ctags 사용
대략 아래와 같이 스크립트를 만들어서 쓰면 되겠다.




출처
http://kldp.org/node/19370

Trackback Address :: http://seirion.com/trackback/205 관련글 쓰기

댓글을 달아 주세요

  1. 바보세룐 2010/10/21 18:17 Address Modify/Delete Reply

    참고 : 자바에서 vim 사용 하기 설정
    http://kwon37xi.egloos.com/1643980

안드로이드에서 네트워크를 이용하는 어플인 경우, 현재 네트워크 상태를 다음과 같이 체크 할 수 있다.




* 다음은 안드로이드 레퍼런스 사이트에서 일부 발췌.

public boolean isAvailable ()

Since: API Level 1

Indicates whether network connectivity is possible. A network is unavailable when a persistent or semi-persistent condition prevents the possibility of connecting to that network. Examples include

  • The device is out of the coverage area for any network of this type.
  • The device is on a network other than the home network (i.e., roaming), and data roaming has been disabled.
  • The device's radio is turned off, e.g., because airplane mode is enabled.
Returns
  • true if the network is available, false otherwise

public boolean isConnected ()

Since: API Level 1

Indicates whether network connectivity exists and it is possible to establish connections and pass data.

Returns
  • true if network connectivity exists, false otherwise.



* Manifest 에서 ACCESS_NETWORK_STATE 권한을 설정해야 함.

Trackback Address :: http://seirion.com/trackback/203 관련글 쓰기

댓글을 달아 주세요

  1. 바보세룐 2010/12/03 22:45 Address Modify/Delete Reply

    3g 와 Wi-Fi 를 모두 끄면 netInfo 에 null 이 날라온다. 이거도 체크 해야 함.

Java's Primitive Data Types

boolean

1-bit. May take on the values true and false only.

true and false are defined constants of the language and are not the same as True and False, TRUE and FALSE, zero and nonzero, 1 and 0 or any other numeric value. Booleans may not be cast into any other type of variable nor may any other variable be cast into a boolean.

byte

1 signed byte (two's complement). Covers values from -128 to 127.

short

2 bytes, signed (two's complement), -32,768 to 32,767

int

4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647. Like all numeric types ints may be cast into other numeric types (byte, short, long, float, double). When lossy casts are done (e.g. int to byte) the conversion is done modulo the length of the smaller type.

long

8 bytes signed (two's complement). Ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.

float

4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).

Like all numeric types floats may be cast into other numeric types (byte, short, long, int, double). When lossy casts to integer types are done (e.g. float to short) the fractional part is truncated and the conversion is done modulo the length of the smaller type.

double
8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).
char

2 bytes, unsigned, Unicode, 0 to 65,535

Chars are not the same as bytes, ints, shorts or Strings.



출처 :
http://www.cafeaulait.org/course/week2/02.html

Trackback Address :: http://seirion.com/trackback/202 관련글 쓰기

댓글을 달아 주세요

  1. 바보세룐 2010/09/28 11:58 Address Modify/Delete Reply

    long 이 8 byte 였다니 ㅠㅠ
    게다가 unsigned integer 타입은 존재하지 않고,
    char 만이 unsigned 로 사용된다 -_-;;

    요건 참고.
    http://mindprod.com/jgloss/unsigned.html