大家帮忙看一下,为什么参数没有传入
//4、定义一个基类Person,从它派生出类Student和类Worker,再由类Student和Worker共同派生出WorStu。
//类Person的属性有姓名、年龄、性别,操作有设置姓名、年龄、性别和显示信息等。类Student的属性增加
//系别、专业和学号属性及相应的操作。类Worker新增部门和工作属性及相应操作。在主函数中声明一个
//WorStu最远派生类的对象,显示相关信息。
#include <iostream>
using namespace std;
class Person
{
public:
Person(){}
~Person(){}
void set_name(string);
void set_age(int);
void set_sex(string);
string show_name(){return name ;}
int show_age(){return age ;}
string show_sex(){return sex ;}
void display();
protected:
string name ;
int age ;
string sex ;
};
class Student:virtual public Person
{
public:
Student(){}
~Student(){}
void set_department(string);
void set_major(string) ;
void set_id(long) ;
string show_department(){return department ;}
string show_major(){return major ;}
long show_id(){return id ;}
protected:
string department ;
string major ;
long id ;
};
class Worker:virtual public Person
{
public:
Worker(){}
~Worker(){}
void set_section(string) ;
void set_job(string);
string show_section(){return section ;}
string show_job(){return job ;}
protected:
string section ;
string job ;
};
class WoeStu:public Student ,public Worker
{
public:
void show() ;
};
void Person::set_name(string a)
{
name = a ;
}
void Person::set_age(int a)
{
age = a ;
}
void Person::set_sex(string a)
{
sex = a ;
}
void Person::display()
{
cout<<"name:\n";
show_name();
cout<<"age:\n";
show_age();
cout<<"sex:\n";
show_sex();
}
void Student::set_department(string a )
{
department = a ;
}
void Student::set_major(string a)
{
major = a ;
}
void Student::set_id(long a)
{
id = a ;
}
void Worker::set_section(string a)
{
section = a ;
}
void Worker::set_job(string a )
{
job = a ;
}
void WoeStu::show()
{
display();
cout<<"department:\n";
show_department();
cout<<"major:\n";
show_major();
cout<<"id:\n";
show_id();
cout<<"section:\n";
show_section();
cout<<"job:\n";
show_job();
}
int main()
{
WoeStu WS ;
WS.set_name("Tom");
WS.set_age(25);
WS.set_sex("man");
WS.set_department("computer science ");
WS.set_major("Computer Science and Technology");
WS.set_id(11320088);
WS.set_section("export");
WS.set_job("sales");
WS.show();
return 0 ;
}主函数参数没有起作用.
...全文
相关推荐
PHP根据传入参数合并多个JS和CSS文件的简单实现
主要介绍了PHP合并多个JS和CSS文件的简单实现,本文使用了一种比较简单的方法,重在揭示实现原理,需要的朋友可以参考下
jquery插件jbox使用iframe关闭问题
此按钮调用close方法关闭,弹出窗口,没有办法关闭,因为close方法需要以个参数,参数应该是那个iframe但是将其传入并不生效,不知道为什么在网上查找也没有找到解决方案。。 最后只好自己改其源码,在其close方法第一句中增加以下代码: if(box==undefined){ box=jBox.boxes[0]; } 然后用:window.parent.window.jBox.close();调用此方法。
深入解析Java编程中方法的参数传递
主要介绍了Java编程中方法的参数传递,是Java入门学习中的基础知识,需要的朋友可以参考下
c函数调用-不使用函数返回值
c函数调用-不使用函数返回值c函数调用-不使用函数返回值
函数参数的传递
专门讲解函数参数的传递的。希望学学,有很大的帮助


