学习C++——只声明忘记定义了

#include <iostream>
#include <list>
#include <string> using namespace std;
class Employee
{
string family_name;
short department;
public:
Employee(const string& name,int dept);
virtual void print() const;
};
Employee::Employee(const string& name,int dept):family_name(name),department(dept){}
void Employee::print() const
{
cout << family_name << '\t' << department << endl;
} class Manager:public Employee
{
list<Employee*> group;
short level;
public:
Manager(const string& name,int dept,int lvl);
void print() const;
};
Manager::Manager(const string& name,int dept,int lvl):Employee(name,dept),level(lvl){}
void Manager::print() const
{
Employee::print();
cout << "\tlevel" << level << endl;
}
void print_list(const list<Employee*>& s)
{
for(list<Employee*>::const_iterator p=s.begin();p!=s.end();++p)
(*p)->print();
} int main()
{
//cout << "Hello world!" << endl;
Employee e("Brown",);
Manager m("Smith",,);
list<Employee*> empl;
empl.push_front(&e);
empl.push_front(&m);
print_list(empl);
return ;
}

废话少说,直接上代码;红色部分,就是当初自己以为是声明定义的,但是后来才发现,我居然把声明当定义来用,硬伤啊。

上一篇:2011 Multi-University Training Contest 1 - Host by HNU


下一篇:架构验证过程发现非数据类型错误 validation found non-data type errors