- 博客(0)
- 资源 (6)
- 收藏
- 关注
C++程序调试
#include <iostream>
using namespace std;
class Tree
{
public:
Tree( int age ) ;
void Grow( int years ) ;
int Age() const { cout<<ages; return ages;}
private:
int ages;
};
Tree::Tree( int age )
{
ages=age;
}
Tree::Grow( int years )
{
ages+=years;
}
int main()
{
Tree t(15);
t.Grow(10);
t.Age();
return 0;
}
2011-10-24
C++调试程序
#include"iostream"
using namespace std;
class Dog
{
public:
Dog(int Age=0,int Weight=0);
int GetAge()
{ return age; }
int GetWeight()
{ return weight; }
private:
int age,weight;
};
Dog::Dog(int Age,int Weight)
{
age=Age;
weight=Weight;
}
int main()
{
Dog r(2,3);
cout<<r.GetAge()<<","<<r.GetWeight()<<endl;
return 0;
}
2011-10-24
C++程序调试
C++程序调试的电子文档
using namespace std;
class Rectangle
#include"iostream"
{
public:
Rectangle(int xx1=0,int yy1=0,int xx2=0,int yy2=0);
int GetX1()
{ return x1;}
int GetY1()
{ return y1;}
int GetX2()
{ return x2;}
int GetY2()
{ return y2;}
int area();
private:
int x1,y1,x2,y2;
};
Rectangle::Rectangle(int xx1,int yy1,int xx2,int yy2)
{
x1=xx1;
y1=yy1;
x2=xx2;
y2=yy2;
}
Rectangle::area()
{
return (x2-x1)*(y2-y1);
}
int main()
{
int x1,x2,y1,y2;
cout<<"请输入左下角的两个坐标和右上角的两个坐标:"<<endl;
cin>>x1>>y1>>x2>>y2;
Rectangle r(x1,y1,x2,y2);
cout<<"左下角的两个坐标和右上角的两个坐标是:"<<r.GetX1()<<","<<r.GetY1()<<","<<r.GetX2()<<","<<r.GetY2()<<endl;
cout<<"该矩形的面积是:"<<r.area()<<endl;
return 0;
}
2011-10-24
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人