'Programming'에 해당되는 글 1711건

  1. 2013.03.04 c++ namespace
  2. 2013.03.03 c++ class와 struct
  3. 2013.02.23 php-mobile-detect
  4. 2013.02.22 index.php가 다운받아지는 문제점 -_-
  5. 2013.02.17 CUDA Capability별 기능차이
  6. 2013.02.17 Nvidia GTX 시리즈별 코드네임
  7. 2013.02.17 cuda deviceQuery on GTX650
  8. 2013.02.16 cuda 5.0
  9. 2013.02.15 c++ cout 제어하기
  10. 2013.02.15 c++ inheritance(상속)
Programming/C++ STL2013. 3. 4. 00:18
namespace는 어떻게 보면 java에서의 패키지와 유사한 묶음에 대한 접근관리라고 하면 되려나?

아래와 같은형식으로 선언이 되며
namespace _spacename_
{


다른 namespace 에서는 동일한 변수 명을 선언해도 문제가 없다.
대신에 :: scope 연산자를 통해서
어떠한 영역의 변수인지를 알려주어야 한다.

물론 namespace 역시 선언되지 이전에 먼저 사용할수는 없으며
사용시에는 에러가 발생한다.
using namespace std;
using namespace first;

namespace first
{
int x = 5;
int y = 10;
}

namespace second
{
double x = 3.1416;
double y = 2.7183;
}

int _tmain(int argc, _TCHAR* argv[])
{
cout << x << endl;
cout << y << endl;
cout << second::x << endl;
cout << second::y << endl;
return 0;
} 

cpp_console.cpp(7) : error C2871: 'first' : 같은 이름을 가진 네임스페이스가 없습니다.
cpp_console.cpp(23) : error C2065: 'x' : 선언되지 않은 식별자입니다.
cpp_console.cpp(24) : error C2065: 'y' : 선언되지 않은 식별자입니다. 

물론, using은 중복되는 여러개를 사용할 수 있으나
using namespace std;

namespace first
{
int x = 5;
int y = 10;
}

namespace second
{
double x = 3.1416;
double y = 2.7183;
}

using namespace first;

int _tmain(int argc, _TCHAR* argv[])
{
cout << x << endl;
cout << y << endl;
cout << second::x << endl;
cout << second::y << endl;
return 0;
} 
[링크 : http://www.cplusplus.com/doc/tutorial/namespaces/]

아무래도 네임스페이스 내에 어떤 변수가 있을지 모르니
되도록이면 여러개의 using namespace는 쓰지 않는게 정신건강에 좋을듯 하다. 
실험은 조금 더 해봐야 겠지만..
해제하는 명령은 존재하지 않는것 같기에
using namespace는 {} 에 영향을 받으므로 블럭으로 감싸서 어느정도 회피는 가능하다고 한다.
[링크 : http://blog.naver.com/harkon/120061325101]

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

c++ function overloading  (2) 2013.03.04
c++ class member function  (0) 2013.03.04
c++ class와 struct  (0) 2013.03.03
c++ cout 제어하기  (0) 2013.02.15
c++ inheritance(상속)  (0) 2013.02.15
Posted by 구차니
Programming/C++ STL2013. 3. 3. 23:48
struct가 변수만 모아놓을수 있었다면
class는 struct에서 확장되어 함수까지 포함하는 개념이다.

단, c++에서 struct로도 함수를 포함해 선언할 수 있지만 class member가 public으로 선언되고
class로 선언시에는 private로 선언되는 차이가 있다고 한다.
[링크 : http://www.dal.kr/chair/cpp/cpp313.html ]

class의 접근제어는
public:
private:
protected: 
로 만들어 지며

class testclass
{
private:
    int priv_a;

public:
    int pub_a;

private:
    int priv_b;
식으로 접근을 제어할 수 있다.
단, 기본적으로 private로 되고 선언된 아래로는 끝까지 이어지니 구획을 구분해서 쓰는게 용이하고
private는 위에서 서술하였지만, 기본적으로 설정이 되니 일반적으로는 public: 만 명시적으로 사용한다.

물론 constructor / destructor 도 강제로(?) private로 만들수는 있지만
그럼 그걸 어떻게 쓸래? 라는 문제가 발생하니 생성자와 파괴자는 public: 으로 선언하자

using namespace std;

class CRectangle {
int width, height;
CRectangle (int,int);

public:
int area () {return (width*height);}
};

CRectangle::CRectangle (int a, int b) {
width = a;
height = b;
}

int _tmain(int argc, _TCHAR* argv[])
{
CRectangle rect (3,4);
CRectangle rectb (5,6);
cout << "rect area: " << rect.area() << endl;
cout << "rectb area: " << rectb.area() << endl;
return 0;
}

cpp_console.cpp(25) : error C2248: 'CRectangle::CRectangle' : private 멤버('CRectangle' 클래스에서 선언)에 액세스할 수 없습니다.
cpp_console.cpp(11) : 'CRectangle::CRectangle' 선언을 참조하십시오.
cpp_console.cpp(9) : 'CRectangle' 선언을 참조하십시오.
cpp_console.cpp(26) : error C2248: 'CRectangle::CRectangle' : private 멤버('CRectangle' 클래스에서 선언)에 액세스할 수 없습니다.
cpp_console.cpp(11) : 'CRectangle::CRectangle' 선언을 참조하십시오.
cpp_console.cpp(9) : 'CRectangle' 선언을 참조하십시오. 

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

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

c++ class member function  (0) 2013.03.04
c++ namespace  (0) 2013.03.04
c++ cout 제어하기  (0) 2013.02.15
c++ inheritance(상속)  (0) 2013.02.15
c++ template  (0) 2013.02.15
Posted by 구차니
Programming/web 관련2013. 2. 23. 11:45
매우단순한 방법으로 mobile 여부를 판단하는 모듈이다.
캐노니컬 등록되지 않아서 구글 코드에서 다운받아야 한다.

<?php
include 'Mobile_Detect.php';
$detect = new Mobile_Detect();

if ($detect->isMobile()) {
    // Any mobile device.
}
?> 

[링크 : http://code.google.com/p/php-mobile-detect/]

'Programming > web 관련' 카테고리의 다른 글

wan 에서 mac address 얻기  (0) 2013.07.09
축약주소 만들기 서비스  (0) 2013.07.08
php if/else/echo  (0) 2012.11.30
TD 태그 - Chrome 과 IE 차이?  (0) 2011.05.30
IE8 / Chrome으로 HTML 분석하기  (2) 2011.03.09
Posted by 구차니
Programming/php2013. 2. 22. 20:27
다른 원인도 있겠지만...
내가 겪은 이유는.. 황당 그 자체!!!


index.php
index.html.bak


두개의 파일이 존재했는데, 파일의 문제인지
index.php의 내용이 다운받아지고 보여지지 않는다 -_-

결론 : index.php를 쓰려면 index.html.bak 라던가 이런 유사 index 파일들을 조심하자? 

'Programming > php' 카테고리의 다른 글

php framework / 읽을꺼리  (0) 2014.04.09
php 메뉴얼  (0) 2014.03.28
php $_SERVER 변수  (0) 2013.07.07
php ++,-- 연산자  (0) 2012.12.03
php 간단정리  (0) 2012.11.26
Posted by 구차니
Programming/openCL & CUDA2013. 2. 17. 11:11
CUDA_Occupancy_Calculator.xls 파일의 GPU Data 탭참조

'Programming > openCL & CUDA' 카테고리의 다른 글

cuda on ubuntu 12.04 LTS  (0) 2014.01.06
cuda 5.5  (0) 2014.01.06
Nvidia GTX 시리즈별 코드네임  (0) 2013.02.17
cuda deviceQuery on GTX650  (0) 2013.02.17
cuda 5.0  (0) 2013.02.16
Posted by 구차니
Programming/openCL & CUDA2013. 2. 17. 11:04
GTX 200 대는 Telsa 코어
GTX 400/500 대는 Fermi 코어

GTX 600/700대는 Kepler 코어 

[링크 : http://en.wikipedia.org/wiki/GeForce_200_Series]
[링크 : http://en.wikipedia.org/wiki/GeForce_400_Series]
[링크 : http://en.wikipedia.org/wiki/GeForce_500_Series]
[링크 : http://en.wikipedia.org/wiki/GeForce_600_Series]
[링크 : http://en.wikipedia.org/wiki/GeForce_700_Series]

'Programming > openCL & CUDA' 카테고리의 다른 글

cuda 5.5  (0) 2014.01.06
CUDA Capability별 기능차이  (0) 2013.02.17
cuda deviceQuery on GTX650  (0) 2013.02.17
cuda 5.0  (0) 2013.02.16
cuda shared memory의 결합법칙?  (0) 2012.09.20
Posted by 구차니
Programming/openCL & CUDA2013. 2. 17. 10:52
특이사항으로는
2 Multiprocessor 에 개당 192개의 CUDA core란거?
그러고 보니.. 블럭당 shared memory도 48KB로 늘어난것 같은데..

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\bin\win32\Release>deviceQuery.exe
deviceQuery.exe Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 650"
  CUDA Driver Version / Runtime Version          5.0 / 5.0
  CUDA Capability Major/Minor version number:    3.0
  Total amount of global memory:                 1024 MBytes (1073741824 bytes)
  ( 2) Multiprocessors x (192) CUDA Cores/MP:    384 CUDA Cores
  GPU Clock rate:                                1059 MHz (1.06 GHz)
  Memory Clock rate:                             2500 Mhz
  Memory Bus Width:                              128-bit
  L2 Cache Size:                                 262144 bytes
  Max Texture Dimension Size (x,y,z)             1D=(65536), 2D=(65536,65536), 3D=(4096,4096,4096)
  Max Layered Texture Size (dim) x layers        1D=(16384) x 2048, 2D=(16384,16384) x 2048
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Maximum sizes of each dimension of a block:    1024 x 1024 x 64
  Maximum sizes of each dimension of a grid:     2147483647 x 65535 x 65535
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  CUDA Device Driver Mode (TCC or WDDM):         WDDM (Windows Display Driver Model)
  Device supports Unified Addressing (UVA):      No
  Device PCI Bus ID / PCI location ID:           1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 5.0, CUDA Runtime Version = 5.0, NumDevs = 1, Device0 = GeForce GTX 650


2012/06/02 - [Programming/openCL / CUDA] - CUDA devicequery - ION 330
2011/01/02 - [Programming/openCL / CUDA] - deviceQuery on 8600GT 512MB + CUDA 하드웨어 구조

'Programming > openCL & CUDA' 카테고리의 다른 글

CUDA Capability별 기능차이  (0) 2013.02.17
Nvidia GTX 시리즈별 코드네임  (0) 2013.02.17
cuda 5.0  (0) 2013.02.16
cuda shared memory의 결합법칙?  (0) 2012.09.20
cudaMalloc 시작 위치?  (0) 2012.07.11
Posted by 구차니
Programming/openCL & CUDA2013. 2. 16. 20:44
...


버전만 올라가는구나..
내 능력은 그대로인데 ㅠ.ㅠ


그래픽 카드도 GTX650 으로 질렀으니 공부좀 하자!!! ㅠ.ㅠ





[링크 : https://developer.nvidia.com/cuda-downloads]

'Programming > openCL & CUDA' 카테고리의 다른 글

Nvidia GTX 시리즈별 코드네임  (0) 2013.02.17
cuda deviceQuery on GTX650  (0) 2013.02.17
cuda shared memory의 결합법칙?  (0) 2012.09.20
cudaMalloc 시작 위치?  (0) 2012.07.11
cudemMemcpy()  (0) 2012.06.07
Posted by 구차니
Programming/C++ STL2013. 2. 15. 23:52
그냥 sprintf 쓰는게 편할지도..

#include <iomanip>
를 포함해서 사용하며
setiosflag()
setfill()
setw()
setprecision()
함수등을
"cout <<" 이후에 넣어서 설정을 하여 사용한다.


[링크 : http://arachnoid.com/cpptutor/student3.html]
[링크 : http://www.cplusplus.com/reference/iolibrary/]
[링크 : http://msdn.microsoft.com/ko-kr/library/943z481t.aspx]

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

c++ namespace  (0) 2013.03.04
c++ class와 struct  (0) 2013.03.03
c++ inheritance(상속)  (0) 2013.02.15
c++ template  (0) 2013.02.15
Essential C++  (0) 2013.02.14
Posted by 구차니
Programming/C++ STL2013. 2. 15. 23:44
java를 안쓰고 c만 쓰다 보니
class나 class의 상속에 대한 개념만 알지, 직접 사용해본적이 없어서 잘 모르겠지만..

아무튼 java의 extend 키워드 대신 c++에서는
: 를 이용해서 상속을 하게 된다.

그리고 java에서는 복잡성의 문제로 다중상속을 지원하지 않지만
c에서는 다중상속을 지원하므로 , 로 여러개의 클래스를 적어줄 수 있다.

class derived_class_name: public base_class_name;
class derived_class_name: public base_class_name, public base_class_name;

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



다중상속 예
class CRectangle: public CPolygon, public COutput; // CPolygon과 COutput 클래스로 부터 상속
class CTriangle: public CPolygon, public COutput;

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

c++ class와 struct  (0) 2013.03.03
c++ cout 제어하기  (0) 2013.02.15
c++ template  (0) 2013.02.15
Essential C++  (0) 2013.02.14
참조에 의한 전달(pass by reference)  (0) 2013.02.09
Posted by 구차니