类中定义构造函数时为什么加void是错的?
#include "iostream.h"
class tool { public: void tool() //这里加了void就错了,怎么讲? { weight=1000; height=9000; length=8000; width=7000; cout<<weight<<" "<<height<<" "<<length<<" "<<width<<endl;} protected: int weight; int height; int length; int width; }; class desk { public: void desk()//这里加了void就错了,怎么讲? { weight=1000; height=9000; length=8000; width=7000; cout<<weight<<" "<<height<<" "<<length<<" "<<width<<endl;} protected: int weight; int height; int length; int width; };
void fn() { tool a; desk b; } void main() { fn(); }
[此贴子已经被作者于2004-11-12 08:25:31编辑过]