|
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);
}
답변을 부탁드립니다. 꼭 알고 싶습니다..............박카스..........선전 아닙니다.
|