我有一个,不过稍微有点不一样,是回答以前的一个同学的问题给编的,
等会回我宿舍给你传过去,你自己改改
模块都构建好了是类结构的,不知道你要不???
哎!!好像不可以存文件里,不合要求哦。。。。。
以下是代码:
c++ vc6.0或7.0下代码是
#include
#include
using namespace std;
//构造学生类 属性有:学号,姓名,年龄,性别,班级号
class CStudent
{
public: //公有类型声明
char strName[12]; //姓名
char strStuNO[9]; //学号
unsigned int age; //年龄
bool isman; //性别
void SetScore(float s1,float s2,float s3)
//成员函数,设置三门课成绩
{
fScore[0]=s1;
fScore[1]=s2;
fScore[2]=s3;
}
float GetAverage(); //均分
CStudent(char str[9]) //第一个构造函数
{
strcpy(strStuNO,str);
}
CStudent(char str[9],char Name[12]) //第二个构造函数
{
strcpy(strStuNO,str);
strcpy(strName,Name);
}
//利用下面构造函数初始化年龄为18
CStudent(unsigned int IN_age) //第三个构造函数,
{
age=IN_age;
}
friend unsigned long int CIn(CStudent &CStu );
private:
float fScore[3];
enum{ClassNum = 20080715 };
//static const unsigned long int ClassNum=20080715;
//班级号:你可以自己修改2008级07系15班,嘎嘎
//将上面数字改一下
};
float CStudent::GetAverage()
{
return (float)((fScore[0]+fScore[1]+fScore[2])/3.0);
}
unsigned long int CIn(CStudent &CStu )
{unsigned long int n;
n=CStu.ClassNum;
return n;
}
void main()
{
const unsigned long int ClassNum=20080715;
unsigned long int n;
int AgeIn;
char str1[9];
char str2[9],strN[12];
cout<<"*****************************************************"<
cout<<"调用一个参数的构造函数,请输入学号:"<
CStudent Onestu(str1);
cout<<"你输入的学号为:"<
//第二个同学信息
cout<<"调用两个参数的构造函数,请输入学号:"<
cout<<"请输入姓名:"<
CStudent Twostu(str2,strN);
cout<<"你输入的学号为:"<
//初始化年龄为18
cout<<"你可以输入年龄,建立以年龄为参数的对象:"<
cin>>AgeIn;
CStudent Thrstu(AgeIn);
cout<<"第三位同学信息建立啦!"<
cout<<"友元函数声明他们的班级为:"<
system("pause");
}
vc2005版本稍微有些不同:
#include
#include
using namespace std;
//构造学生类 属性有:学号,姓名,年龄,性别,班级号
class CStudent
{
public: //公有类型声明
char strName[12]; //姓名
char strStuNO[9]; //学号
unsigned int age; //年龄
bool isman; //性别
void SetScore(float s1,float s2,float s3)
//成员函数,设置三门课成绩
{
fScore[0]=s1;
fScore[1]=s2;
fScore[2]=s3;
}
float GetAverage(); //均分
CStudent(char str[9]) //第一个构造函数
{
strcpy_s(strStuNO,str);
}
CStudent(char str[9],char Name[12]) //第二个构造函数
{
strcpy_s(strStuNO,str);
strcpy_s(strName,Name);
}
//利用下面构造函数初始化年龄为18
CStudent(unsigned int IN_age) //第三个构造函数,
{
age=IN_age;
}
friend unsigned long int CIn(CStudent &CStu );
private:
float fScore[3];
static const unsigned long int ClassNum=20080715;
//班级号:你可以自己修改2008级07系15班,嘎嘎
//将上面数字改一下
};
float CStudent::GetAverage()
{
return (float)((fScore[0]+fScore[1]+fScore[2])/3.0);
}
unsigned long int CIn(CStudent &CStu )
{unsigned long int n;
n=CStu.ClassNum;
return n;
}
void main()
{
unsigned long int n;
int AgeIn;
char str1[9];
char str2[9],strN[12];
cout<<"*****************************************************"<
cout<<"调用一个参数的构造函数,请输入学号:"<
CStudent Onestu(str1);
cout<<"你输入的学号为:"<
//第二个同学信息
cout<<"调用两个参数的构造函数,请输入学号:"<
cout<<"请输入姓名:"<
CStudent Twostu(str2,strN);
cout<<"你输入的学号为:"<
//初始化年龄为18
cout<<"你可以输入年龄,建立以年龄为参数的对象:"<
cin>>AgeIn;
CStudent Thrstu(AgeIn);
cout<<"第三位同学信息建立啦!"<
cout<<"友元函数声明他们的班级为:"<
system("pause");
}
以下是运行结果:
*****************************************************
** C++学生类的构造 **
*****************************************************
调用一个参数的构造函数,请输入学号:
0803
你输入的学号为:0803
第一位同学信息建立啦!
请按任意键继续. . .
调用两个参数的构造函数,请输入学号:
0802
请输入姓名:
liming
你输入的学号为:0802
你输入的姓名为:liming
第二位同学信息建立啦!
请按任意键继续. . .
你可以输入年龄,建立以年龄为参数的对象:
请输入年龄(比如18岁):18
第三位同学信息建立啦!
他(她)的年龄为:18岁
友元函数声明他们的班级为:20080715
*****************************************************
** 谢谢使用 **
*****************************************************
分太少
知道里这方面高手不多
我问这种问题一般是200分以上才可能有人帮忙写点
要不人家只会帮你找到复制粘贴的那种
给你还不一定好使
发消息给你了
DROP DATABASE IF EXISTS ENOVA;
CREATE DATABASE ENOVA;
USE ENOVA;
CREATE TABLE STUDENT (
ID int(11) NOT NULL auto_increment,
NUMBER char(15) NOT NULL UNIQUE,
NAME varchar(4) NOT NULL ,
SEX varchar(1) default NULL,
NATION varchar(10) default NULL,
ENROLL_YEAR YEAR(4) NOT NULL ,
BIRTHDAY date default NULL,
BIRTH_PLACE varchar(50) default NULL,
PASSWORD char(15) NOT NULL ,
CLASS_ID int(11) NOT NULL ,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE TEACHER(
ID int(11) NOT NULL auto_increment,
NAME varchar(4) default NULL ,
SEX varchar(1) default NULL,
USERNAME char(15) NOT NULL UNIQUE ,
PASSWORD char(15) NOT NULL ,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE DEPARTMENT(
ID int(11) NOT NULL auto_increment,
NAME varchar(20) NOT NULL,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE SPECIAL(
ID int(11) NOT NULL auto_increment,
NAME varchar(20) NOT NULL,
DEPARTMENT_ID int(11) NOT NULL ,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE CLASS(
ID int(11) NOT NULL auto_increment,
NAME varchar(20) NOT NULL,
TEACHER_ID int(11) NOT NULL ,
SPECIAL_ID int(11) NOT NULL ,
YEAR year(4) NOT NULL ,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE COURSE(
ID int(11) NOT NULL auto_increment,
NAME varchar(20) NOT NULL,
TEACHER_ID int(11) NOT NULL ,
HOUR int(4) default NULL,
CREDIT float(2,1) NOT NULL ,
YEAR year(4) default NULL,
TERM varchar(1) default NULL,
EXAM_MODE varchar(2) default NULL,
EXAM_TYPE varchar(2) default NULL,
TYPE varchar(2) default NULL,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE SCORE(
COURSE_ID int(11) NOT NULL ,
STUDENT_ID int(11) NOT NULL ,
VALUE int(4) default NULL ,
DATE date NOT NULL ,
PRIMARY KEY (STUDENT_ID,COURSE_ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE ROOT(
ID int(11) NOT NULL auto_increment,
USERNAME char(15) NOT NULL UNIQUE ,
PASSWORD char(15) NOT NULL ,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE CLASS_COURSE(
CLASS_ID int(11) NOT NULL ,
COURSE_ID int(11) NOT NULL ,
PRIMARY KEY (CLASS_ID,COURSE_ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table STUDENT add constraint FK_STUDENT_CLASS
foreign key(CLASS_ID) references CLASS(ID) on delete cascade;
alter table SPECIAL add constraint FK_SPECIAL_DEPARTMENT
foreign key(DEPARTMENT_ID) references DEPARTMENT(ID) on delete cascade;
alter table CLASS add constraint FK_CLASS_TEACHER
foreign key(TEACHER_ID) references TEACHER(ID) on delete cascade;
alter table CLASS add constraint FK_CLASS_SPECIAL
foreign key(SPECIAL_ID) references SPECIAL(ID) on delete cascade;
alter table SCORE add constraint FK_SCORE_COURSE
foreign key(COURSE_ID) references COURSE(ID) on delete cascade;
alter table SCORE add constraint FK_SCORE_SUTDENT
foreign key(STUDENT_ID) references STUDENT(ID) on delete cascade;
alter table CLASS_COURSE add constraint FK_CC_CLASS
foreign key(CLASS_ID) references CLASS(ID) on delete cascade;
alter table CLASS_COURSE add constraint FK_CC_COURSE
foreign key(COURSE_ID) references COURSE(ID) on delete cascade;
alter table COURSE add constraint FK_COURSE_TEACHER
foreign key(TEACHER_ID) references TEACHER(ID) on delete cascade;
insert into ROOT(USERNAME,PASSWORD) values('vlinux','lovefs');
create trigger CLASS_COURSE_DELETE BEFORE DELETE ON CLASS_COURSE
FOR EACH ROW DELETE FROM SCORE WHERE COURSE_ID=old.COURSE_ID
and STUDENT_ID in (SELECT ID FROM STUDENT WHERE CLASS_ID=old.CLASS_ID);
grant all on ENOVA.* to enova@localhost identified by "enova" with grant option;
数据结构文件可以从/enova/src/enova/ENOVA_DB.SQL中找到
管理员初始帐号/密码为:vlinux/lovefs
你的分太少了。。。