C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[38458] Input & Output ^^
황경록 [mpbox] 774 읽음    2004-12-21 12:18
안녕하세요?

Input 과 Output 은 재차 강조를 해도 지나치지 않죠.

우선 무엇을 하고 싶은 가를 정리해 보겠습니다.

학생이 있습니다.
수학, 영어, 국어 과목이 있습니다.
총점을 알고 싶습니다.
평균을 알고 싶습니다.

학생을 클래스와 해서 위의 데이터를 처리해 보기로 하죠.

class TStudent
{
    private:
        AnsiString szName;  // 학생 이름
        int FHan;   // 국어 점수
        int FEng;   // 영어 점수
        int FMath;   // 수학 점수

    public:
        void __fastcall SetData( AnsiString szName, int iHan, int iEng, int iMath ); // 학생의 이름과 점수 입력
        int __fastcall GetTotal( void );   // 총점 얻기
        int __fastcall GetAverage( void );   // 평균 얻기
};

간단하게 위 클래스처럼 만들 수 있을 겁니다.

구현부는 -_-;;; 워낙 단순하니 하실수 있겠죠.



쥬신 님이 쓰신 글 :
: c++책에 있는것과 제가 만든 것은 값은 같은 겂니다. 빌더로 옮길떄 다른 방법이 없을 까요 꼭 CLASS를 이용하여 만들고 싶구요..다른 방법으로 프로그램을 만들고 싶습니다.
: /*                                                           //C++프로그램이고 아래가 제가 만든 프로그램입니다.
: #include <iostream>        
: using namespace std;
: class Student
: {
:     protected:
:     private:
:     public:
:         int no;
:         char name[10];
:         int eng;
:         int math;
:         void TData( );
: };
:
: void Student::TData( )
: {
:     cout<<no<<endl;
:     cout<<name<<endl;
:     cout<<eng<<endl;
:     cout<<math<<endl;
: }
: int main()
: {
:     Student kim;
:     no = 1;
:     strcpy(name, "김성주");
:     eng = 90;
:     math = 98;
:     kim.TData( );
:     Student lee;
:     no = 2;
:     strcpy(name, "이아랑");
:     eng  = 80;
:     math = 100;
:     lee.TData( );
:     return 0;
: }
: */
: 빌더로 짠거 입니다.
: //---------------------------------------------------------------------------
:
: #ifndef Unit2H
: #define Unit2H
: //---------------------------------------------------------------------------
: class Student
: {
:     protected:
:     private:
:     public:
:         __fastcall  Student(void);
:         __fastcall ~Student(void);
:     public:
:         int no;
:         char name[10];
:         int eng;
:         int math;
:         void __fastcall TData(void);
:         void __fastcall FData(void);
: };
: extern Student Data;
: #endif
: //---------------------------------------------------------------------------
:
: #include <vcl.h>
: #pragma hdrstop
:
: #include "Unit2.h"
:
: //---------------------------------------------------------------------------
:
: #pragma package(smart_init)
: Student Data;
: __fastcall Student:: Student(void)
: {
: }
: void __fastcall Student::TData(void)
: {
:     Student kim;
:     no = 1;
:     strcpy(name, "김성주");
:     eng = 90;
:     math = 98;
: }
: void __fastcall Student::FData(void)
: {
:     Student lee;
:     no = 2;
:     strcpy(name, "이아랑");
:     eng  = 80;
:     math = 100;
: }
: __fastcall Student::~Student(void)
: {
: }
: //---------------------------------------------------------------------------
:
: #include <vcl.h>
: #pragma hdrstop
:
: #include "Unit1.h"
: #include "Unit2.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __fastcall TForm1::TForm1(TComponent* Owner)
:         : TForm(Owner)
: {
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::Button1Click(TObject *Sender)
: {
:     Data.TData( );
:     Memo1->Lines->Add(Data.no);
:     Memo1->Lines->Add(Data.name);
:     Memo1->Lines->Add(Data.eng);
:     Memo1->Lines->Add(Data.math);
:     Data.FData( );
:     Memo1->Lines->Add(Data.no);
:     Memo1->Lines->Add(Data.name);
:     Memo1->Lines->Add(Data.eng);
:     Memo1->Lines->Add(Data.math);
: }
: 답변을 부탁드립니다. 꼭 알고 싶습니다..............박카스..........선전 아닙니다.

+ -

관련 글 리스트
38450 c++책을 보고 옮긴거 거든요..좀더 간단한 방법이 없을 까요.. 쥬신 840 2004/12/20
38458     Input & Output ^^ 황경록 774 2004/12/21
38452     Re:c++책을 보고 옮긴거 거든요..좀더 간단한 방법이 없을 까요.. 이현진 879 2004/12/21
38455         Re:Re:c++책을 보고 옮긴거 거든요..좀더 간단한 방법이 없을 까요.. 이현진 1093 2004/12/21
38453         Re:Re:답변고맙 습니다..너무 어렵군요ㅜㅜ... 쥬신 723 2004/12/21
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.