코드

    상속에 대해서

    상속에 대해서 보다가 궁금한게 생겼다. virtual 함수를 선언할 때 {] 뒤에 ;가 있는 것과 없는 것이 차이가 존재할까? 결론은 차이가 없다이다. (적어도 내 컴파일러는 동일하게 동작하였다.) #include class Test { public: virtual void render() {} virtual void draw() {}; }; class Exam : Test { public: void render() { printf("This is render() \n"); } void draw() { printf("This is draw() \n"); } }; int main(int argc, char *argv[]) { Exam ex; ex.draw(); ex.render(); return 0; }

    java/자바 에서 call back에 대해서 공부해보기 -1

    java/자바 에서 call back에 대해서 공부해보기 -1 1. 목적callback 예제를 작성해보고 사용 방법을 이해해보자.callback을 사용하는 방법을 알게되었다. 1. 환경 셋팅java, ubuntu 14.04 1. SourceCallbackTest.java class Sum { interface OnMaxNumberCb { void onMaxNumber(int number, int exceed); } private int number = 0; private int maxNumber = 0; private OnMaxNumberCb myCallback; public void setOnMaxNumberCb(OnMaxNumberCb callback) { myCallback = callback; }..

    함수의 괄호 뒤에 const를 넣는 이유에 대해서

    여기 저기 검색을 해보니 함수 괄호 뒤에 const를 넣는 의미는, 멤버 변수의 값을 변경하지 않는다. 라는 의미라고 하더라구요(그리고 함수 괄호 뒤에 const를 넣는 함수는 멤벼함수일때만 가능하다고 하네요.) 간단한 실험을 준비해봤습니다. 1. 아래의 코드는 잘 실행되는 코드입니다. #include #include using namespace std; class Tester { private: char m_data[24]; public: void setData(char *input) { strcpy(m_data, input); } const char* getData() const { return m_data; } }; int main() { Tester test; test.setData((char*)..

    jni는 객체 당 하나씩 생성되는 것일까??

    상황:class A 가 존재할 때,A a;A b;이 두개의 jni속의 int 값을 변화를 줄 때, 어떻게 변할까?? 갖고 있는 것 : A.java A.cpp class Good { static { System.loadLibrary("Good"); } native public Good get(); native public void setData(int data); native public int getData(); public void test() { System.out.println("GAOL!!!"); } } class GoodRun { public static void main(String[] args) { System.out.println("test start"); Good go1 = new Goo..

    jni에서 java 클래스 주소 return하기

    상황 ; jni에서 클래스에 해당하는 레퍼런스(객체)가 있는가?그러니깐, jni에서 return 받은 값으로 내가 예상하는(원하는) 객체로 캐스팅을 하여서바로 사용할 수 있닌지. Java:class Good; cpp:Good.cpp 결론은 가능하다.(jobject를 반환하면 된다.) class Good { static { System.loadLibrary("Good"); } native public Good get(); public void test() { System.out.println("GAOL!!!"); } } class GoodRun { public static void main(String[] args) { System.out.println("test start"); Good go = new ..

    [c++] snprintf, sprintf 예제

    sprintf는 문장, 혹은 하나의 버퍼를 타겟 버퍼에 그대로 복사를 하는 것이고, snprint는 크기를 정한 후 복사하는 것이다. #include #include int main(int argc, char* argv[]) { /* sprintf example */ char buf[256]; int len; int i; len = sprintf(buf, "Hello,\n"); for (i=0;i

    java - jni로 hello world 출력하기

    http://bunhere.tistory.com/229 위 블로그를 참고했음을 밝힙니다. 저는 간략히 적겠습니다. 1. 소스를 작성한다 ( Hello.java, hello.c ) 2. 여러 종류의 컴파일을 실행한다. 3. 결과물을 실행시킨다. Hello.java public class Hello { native void printHello(); native void printString(String str); static { System.loadLibrary("hello"); } // hello.c public static void main(String args[]) { Hello hello = new Hello(); hello.printHello(); hello.printString("Hello Wor..

    [JAVA] 계산기 예제 (swing, event, awt, util)

    Java 연습겸 어떤 분이 계산기를 올려주셨길래 따라쳐보면서 연습했습니다.( 원본 : http://djsdj222.blog.me/220170288062 ) import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; public class Calc extends JFrame { JLabel label; JButton bNum[] = new JButton[10]; JButton plus, minus, multi, div, equal, clear; String inputValue; int result; char lastOp; public static void main(String[] args) { new Calc()..