PDA

View Full Version : Cần người giúp về OOP...


Noname.CPP
02-02-2009, 10:06 AM
Có bác nào pro xem giúp em cái bài SV này em sai ở đâu thế ????

Nó cứ báo lỗi ngay getch() quài =.=!

// SV.cpp : Defines the entry point for the console application.
// -[]- Noname.CPP -[]-

#include "iostream.h"
#include "conio.h"
#include "stdio.h"
class student
{

private:
int n;
char ho_ten[20];
char dia_chi[30];
int nam_sinh;
float toan,ly,hoa;

public:
void nhap();
void xuat();
void DTB();
void SV_co_DTB_tren_5();
};

//__________________

void student::nhap()
{
cout<<"\n Nhap SV: ";
cin>>ho_ten;

cout<<"\n Nhap dia chi: ";
cin>>dia_chi;

cout<<"\n Nhap nam sinh: ";
cin>>nam_sinh;

cout<<"\n Nhap diem toan: ";
cin>>toan;

cout<<"\n Nhap diem ly: ";
cin>>ly;

cout<<"\n Nhap diem hoa: ";
cin>>hoa;

DTB=(toan+ly+hoa)/3;

void student::xuat()
{
cout<<"\n sinh vien: "<<ho_ten;
cout<<"\n dia chi: "<<dia_chi;
cout<<"\n nam sinh: "<<nam_sinh;
cout<<"\n diem toan: "<<toan;
cout<<"\n diem ly: "<<ly;
cout<<"\n diem hoa: "<<hoa;
cout<<"\n Diem trung binh: "<<DTB;
cout<<"\n\n";
};

void SV_co_DTB_tren_5()
{
if(DTB > 5)
{
cout<<"\n sinh vien: "<<ho_ten;
cout<<"\n DTB: "<<DTB;
}
else
cout<<"\n Khong co sinh vien nao";
}

void main()
{
clrscr();
int n;
cout<<"\n Nhap vao so SV: ";
cin>>n;

cout<<"\n";
student sv[100];

for(int i=1;i<n;i++)
sv[i].nhap();
cout<<"\n";
for(int i=1;i<n;i++)
sv[i].xuat();

cout<<"\n\n-------------TONG KET--------------";
cout<<"\n\n THONG KE SINH VIEN CO DIEM TRUNG BINH > 5";

for(int i=1;i<n;i++)
sv.[i].DTB();

getch();
}

Noname.CPP
02-02-2009, 03:19 PM
Sao kô ai giúp hết trơn vậy nè....=.=

Noname.CPP
03-02-2009, 07:42 AM
Hix...kô lẽ trong 2T kô có ai pro về OOP sao vậy nè ????? 10 người xem kô ai trả lời...=.=!:2T-bunny-(16)::2T-bunny-(16):

la long
03-02-2009, 09:15 AM
ko ranh c++ lam nen po tay

vtienuit
03-02-2009, 01:52 PM
Có bác nào pro xem giúp em cái bài SV này em sai ở đâu thế ????

Nó cứ báo lỗi ngay getch() quài =.=!

// SV.cpp : Defines the entry point for the console application.
// -[]- Noname.CPP -[]-

#include "iostream.h"
#include "conio.h"
#include "stdio.h"
class student
{

private:
int n;
char ho_ten[20];
char dia_chi[30];
int nam_sinh;
float toan,ly,hoa;

public:
void nhap();
void xuat();
void DTB();
void SV_co_DTB_tren_5();
};

//__________________

void student::nhap()
{
cout<<"\n Nhap SV: ";
cin>>ho_ten;

cout<<"\n Nhap dia chi: ";
cin>>dia_chi;

cout<<"\n Nhap nam sinh: ";
cin>>nam_sinh;

cout<<"\n Nhap diem toan: ";
cin>>toan;

cout<<"\n Nhap diem ly: ";
cin>>ly;

cout<<"\n Nhap diem hoa: ";
cin>>hoa;

DTB=(toan+ly+hoa)/3;

void student::xuat()
{
cout<<"\n sinh vien: "<<ho_ten;
cout<<"\n dia chi: "<<dia_chi;
cout<<"\n nam sinh: "<<nam_sinh;
cout<<"\n diem toan: "<<toan;
cout<<"\n diem ly: "<<ly;
cout<<"\n diem hoa: "<<hoa;
cout<<"\n Diem trung binh: "<<DTB;
cout<<"\n\n";
};

void SV_co_DTB_tren_5()
{
if(DTB > 5)
{
cout<<"\n sinh vien: "<<ho_ten;
cout<<"\n DTB: "<<DTB;
}
else
cout<<"\n Khong co sinh vien nao";
}

void main()
{
clrscr();
int n;
cout<<"\n Nhap vao so SV: ";
cin>>n;

cout<<"\n";
student sv[100];

for(int i=1;i<n;i++)
sv[i].nhap();
cout<<"\n";
for(int i=1;i<n;i++)
sv[i].xuat();

cout<<"\n\n-------------TONG KET--------------";
cout<<"\n\n THONG KE SINH VIEN CO DIEM TRUNG BINH > 5";

for(int i=1;i<n;i++)
sv.[i].DTB(); ?????????/

getch();
}


:2T-bunny-(47)::2T-bunny-(47)::2T-bunny-(47)::2T-bunny-(47)::2T-bunny-(47):

phần đỏ nhé you ! chưa biên dihcj nhưng nhòm thấy nó đã thế rồi

ZzSasukezZ
03-02-2009, 02:20 PM
@vtienuit:Thấy nick uit là bít mình là đồng môn học cùng trường gòi!!!

Noname.CPP
05-02-2009, 08:04 AM
:2T-bunny-(47)::2T-bunny-(47)::2T-bunny-(47)::2T-bunny-(47)::2T-bunny-(47):

phần đỏ nhé you ! chưa biên dihcj nhưng nhòm thấy nó đã thế rồi

Em cũng đã tìm ra rồi, dù sao cũng thanks bác đã giúp đỡ...hơi trễ :2T-bunny-(16):