728x90
C/C++ 컴파일러인 CL에서
warning이 발생하면 error로 인식하기 때문에 warning으로 인해 중단된 상태

해결 : /WX 옵션 삭제 or
project->properties->Threat Warnings As Error 부분을 "No"로 변경
728x90

'Programming > C++은객체지향언어다' 카테고리의 다른 글

g++ for windows  (0) 2008.11.07
집합(차집합, 교집합, 합집합) - cpp  (0) 2008.04.02
ADT array 구현  (0) 2008.03.04
C++ (OOP개념들)  (0) 2008.02.26
C++ (객체)  (0) 2008.02.26
C++ (OOP개념)  (0) 2008.02.26
C++ (개요)  (0) 2008.02.26
728x90

Follow these steps to install g++ (the GNU C++ compiler) for Windows. There is no room for creativity here; you must follow the directions exactly.

  1. Pick the drive and a folder in which you want to install g++. I'll assume that it is C:, but you can choose a different one. If you choose a different drive or a different folder, you'll need to adapt the directions below accordingly.

  2. Download full.exe, an about 14 megabyte executable, to C:\full.exe by right-clicking on the link. Use Save Link As... or Save Target As... Be sure the browser saves the file as C:\full.exe.

  3. Run the downloaded executable. This will install g++ (and a lot of other things that you don't really need) on your hard drive. Go to the C: drive using Windows Explorer and double-click on full.exe. Or, open a DOS window (Start > Programs > Command Prompt), connect to the C: drive using the cd command, and type full.

  4. Locate where the bin folder was created for the g++ installation. On my Windows XP machine, it was created in the following path:
    C:\cygnus\cygwin-b20\H-i586-cygwin32\bin
    
    You now should add it to the PATH environment variable. You do that by following:
       Start -> Control Panel -> System -> Advanced -> Environment Variables
    
    At this point you can see the PATH variable either in the User Variables or in the System Variables. Add the g++ path into the PATH variable. You add it to the end of the existing value separated by a semicolon (';'). Make sure that you do not lose the original value. You are just appending more to the end separated by a semicolon.

  5. Restart your computer. A Cygnus Solutions entry will appear in your Programs menu, and an icon may appear on your desktop. Don't use them! You will use it using the g++ command on a DOS prompt as explained below.

You should now be able to run g++ from a DOS (Command Prompt) window. For example, to compile a file called C:\mine\hello.cpp, connect to the C:\mine folder and enter

       g++ -g hello.cpp -o hello -lm
You'll then be able to run the compiled program by entering hello in the DOS window.

If you've installed Emacs as described here, you will also be able to run g++ from Emacs. If, when you do this, Emacs tries to compile with the command make -k, you made a mistake during the Emacs installation. If you want to learn how to run g++ on emacs, see here.

If you'd like to learn more about where this free compiler came from, we downloaded it from an older site of http://sourceware.org/cygwin/.

If you wish to clean up a little, you may delete the file: full.exe at this point. Your g++ compiler is installed under C:\cygnus.

======================================================================================
사실 위에서 말하는대로 하지 않아도 상관없다.
파일을 받고 더블클릭하면 알아서 설치된다.
설치가 끝나고 나면 환경변수를 등록하도록 하자.

내컴퓨터 오른쪽클릭 -> 속성 -> 고급 -> 환경변수
지정된 PATH + ;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin

728x90

'Programming > C++은객체지향언어다' 카테고리의 다른 글

error C2220: warning treated as error - no object file generated  (0) 2011.07.29
집합(차집합, 교집합, 합집합) - cpp  (0) 2008.04.02
ADT array 구현  (0) 2008.03.04
C++ (OOP개념들)  (0) 2008.02.26
C++ (객체)  (0) 2008.02.26
C++ (OOP개념)  (0) 2008.02.26
C++ (개요)  (0) 2008.02.26
728x90

신중히 생각해서 나누지 않고 바로 코딩에 들어갔더니 역시 구성이 마음에 들지 않는다. 쩝..
사소한 것을 코딩하더라도 천천히 생각해보고 하도록 하자!!

static을 사용해서 집합연산을 만들어봤는데 static에 관한 문법이 다른 언어들과 달라서 멈칫했었다.

element.h



mySet.h


mySet.cpp



insertSortWithSets.cpp

728x90

'Programming > C++은객체지향언어다' 카테고리의 다른 글

error C2220: warning treated as error - no object file generated  (0) 2011.07.29
g++ for windows  (0) 2008.11.07
ADT array 구현  (0) 2008.03.04
C++ (OOP개념들)  (0) 2008.02.26
C++ (객체)  (0) 2008.02.26
C++ (OOP개념)  (0) 2008.02.26
C++ (개요)  (0) 2008.02.26
728x90
  • Design and implement (in C++) an ADT Array that can dynamically grow and shrink as integers are data is inserted and removed. // ADT array 을 하나 맏르어줘서 엄청나게 커질수도 작아질수도 있게 만들어 주는거네요 . Access time to any item in an array (via it's index) should be constant. The cost of an insert into the middle of an array may be O(n). Indexes need not start at zero and may be negative.
  1. The ADT should include the following:
    1. -A default constructor that creates an empty array starting at index 0.
    2. -A constructor taking an intdata [] array that builds an array populated with the items in the array starting at index 0.
    3. -A constructor taking a range int low, int high that builds an empty array ranging from the low index to the high. (Pre: high >= low.)
    4. -A copy constructor array( const array& that ) .
    5. -A destructor. 
    6. -An accessor int size( ) that returns the size of (number of entries in) the array. 
    7. -An accessor int find( intdata n ) that returns the index of element n in the array.
    8. -An accessor int at( intdata n ) that returns the integer at the given index n. 
    9. -A mutator void insert( intdata n ) that inserts the element n at the end of the array.
    10. -A mutator void insert( intdata n, index i ) that inserts the element n into the array at index position i. 
    11. -Amutator void erase( int index ) that removes the element at the given index position in the array. 
    12. -A mutator void clear( ) that empties the array.
    13. Overload the [] operator
    14. Overload the assignment operator =
    15. Overload the operator == to test array equality.
    16. Overload the operator != to test array inequality.

ADT란게 자료의 type에 무관하게 사용하겠다는 겁니다. 뎃글에 자료형을 물어보신 글이 있던데 특정한 자료가 정해진 것아닙니다. C++ 문법에 template이 있는데 이 부분은 표준이 제대로 안되어 있어서 컴파일러마다 조금씩 다르기도 합니다.

배열의 크기가 동적으로 커졌다고 줄었다가 한다고 되어 있습니다. 배열로 지정하고 크기에 따라 deep copy를 통해 크기가 다른 배열로 바꿀 수도 있습니다만 문제에서 O(n)이 예상된다고 하니 링크드리스트를 원하는 것으로 보입니다.


한시간 넘게 붙잡고 있었는데 엉망이다. 귀찮아서 다 inline으로 해버렸고
A constructor taking a range int low, int high that builds an empty array ranging from the low index to the high. (Pre: high >= low.)
이부분... 생성자에서 low와 high값을 argument로 던져주고 배열사이즈를 계산해서 생성하란 것 같은데 무슨 뜻인지, 왜 필요한지 몰라서 제대로 못했다.
그리고 test결과 =연산자가 제대로 작동하지 않는다. 제대로 연산은 되는데 const &로 parameter를 맞추니까 오류나고 그냥 해버리니까 연산이 끝난 후 R-value의 링크가 사라진다. 뭐냐고..

아무튼 문제에 보면 Indexes need not start at zero and may be negative. 이렇게 되어 있는데 그러면 생성할 때 배열의 low와 high를 정하는 것이 아니라 method중에 begin을 결정하는 method가 있으면 되는거 아닌가? 문제를 만든 사람은 뭘 생각한 거지? 내 영어실력이 문젠가?
아무튼 제대로 이해한 사람 있으면 좀 알려주..
728x90

'Programming > C++은객체지향언어다' 카테고리의 다른 글

error C2220: warning treated as error - no object file generated  (0) 2011.07.29
g++ for windows  (0) 2008.11.07
집합(차집합, 교집합, 합집합) - cpp  (0) 2008.04.02
C++ (OOP개념들)  (0) 2008.02.26
C++ (객체)  (0) 2008.02.26
C++ (OOP개념)  (0) 2008.02.26
C++ (개요)  (0) 2008.02.26

+ Recent posts