java用多了吧
登录 | 论坛导航 -> 华新鲜事 -> 技术の宅 | 本帖共有 1 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:hula (等级:7 - 出类拔萃,发帖:3676) 发表:2006-12-19 12:10:29  楼主  关注此帖
为什么以下的C++ code有compile error?Test_Class.cpp ============================== class CRectangle{ int *width, *height; public: CRectangle (int a, int b){ width= new int; height = new int; *width = a; *height = b; } ~CRectangle(){ delete width; delete height; } int area(){ return ((*width)*(*height)); } }; ================================= Do_Factorial.cpp ================================= #include class CRectangle; int main() { CRectangle c(2,3); std::cout (more...)
java用多了吧
#include<iostream>

class CRectangle;

int main()
{
CRectangle c(2,3);
std::cout<<c.area()<<'\n';
}

从个文件来看,没有CRectangle的定义,当然没办法compile,简单一点,#include "Test_Class.cpp"
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
论坛导航 -> 华新鲜事 -> 技术の宅 | 返回上一页 | 本主题共有 1 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码