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
[38453] Re:Re:답변고맙 습니다..너무 어렵군요ㅜㅜ...
쥬신 [chusin] 723 읽음    2004-12-21 09:28
이현진 님이 쓰신 글 :
: : : :

쥬신 님이 쓰신 글 :
: c++책에 있는것과 제가 만든 것은 값은 같은 겂니다. 빌더로 옮길떄 다른 방법이 없을 까요 꼭 CLASS를 이용하여 만들고 싶구요..다른 방법으로 프로그램을 만들고 싶습니다.

:

#include
#include

class Student
{
private:
std::string m_StrName;
int m_nNo;
int m_nEng;
int m_nMath;

public:
explicit __fastcall  Student(int no, const char* name, int eng, int math);
virtual __fastcall ~Student(void);

std::string __fastcall GetName();
int __fastcall GetNo();
int __fastcall GetEng();
int __fastcall GetMath();
};
//---------------------------------------------------------------------------

__fastcall Student::Student(int no, const char* name, int eng, int math)
: m_nNo(no), m_nEng(eng), m_nMath(math), m_StrName(name)
{
}
//---------------------------------------------------------------------------

__fastcall Student::~Student(void) { }
//---------------------------------------------------------------------------

std::string __fastcall Student::GetName() { return m_StrName; }
//---------------------------------------------------------------------------

int __fastcall Student::GetNo() { return m_nNo; }
//---------------------------------------------------------------------------

int __fastcall Student::GetEng(){ return m_nEng; }
//---------------------------------------------------------------------------

int __fastcall Student::GetMath() { return m_nMath; }
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   try {
        std::list< Student* > StudentList;
        StudentList.push_back(new Student(1, "김성주", 90, 98));
        StudentList.push_back(new Student(2, "이아랑", 80, 100));
        StudentList.push_back(new Student(3, "이현진", 20, 10));
       
// ...... 목록 추가

        Memo1->Lines->Clear();
  
        std::list< Student* >::iterator iterator;
        for(iterator=StudentList.begin(); iterator!=StudentList.end(); ++iterator) {
            Memo1->Lines->Add("-------------------------------------");
            Memo1->Lines->Add("Number : "+IntToStr((*iterator)->GetNo()));
            Memo1->Lines->Add("Name   : "+AnsiString((*iterator)->GetName().c_str()));
            Memo1->Lines->Add("English: "+IntToStr((*iterator)->GetEng()));
            Memo1->Lines->Add("Math   : "+IntToStr((*iterator)->GetMath()));
            delete (*iterator);
            (*iterator)=NULL;
        }

        StudentList.clear();
   } catch(const Exception& E) {
       ShowMessage("Exception: "+E.Message);
   } catch(const std::exception& e) {
       ShowMessage("Exception: "+AnsiString(e.what()));
   }
}
//---------------------------------------------------------------------------


+ -

관련 글 리스트
38450 c++책을 보고 옮긴거 거든요..좀더 간단한 방법이 없을 까요.. 쥬신 840 2004/12/20
38458     Input & Output ^^ 황경록 775 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.