为什么以下的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"
class CRectangle;
int main()
{
CRectangle c(2,3);
std::cout<<c.area()<<'\n';
}
从个文件来看,没有CRectangle的定义,当然没办法compile,简单一点,#include "Test_Class.cpp"