新手Visual C++编程问题

来源:百度知道 编辑:UC知道 时间:2024/05/16 17:31:55
我用Visual C++编程程序有多个错误,总共有4个程序,望高手指出错误,并加以修改,重谢
1.
#include<iostream.h>
#include<string.h>
class Person{
public:
char m_strName[20];
long m_ID;
public:
Person(char*strName,long ID){strcpy(m strName,strName);m _ID=ID;}
static long GetID() {return m_ID;}
};
void main()
{
person person1("LiuJun",1101640524);
cout<<"ID=”<<Person::GetID()<<'\n';
}

2.
#include<iostream.h>
class point
{
protected:
int x,y;
public:
point(int a,int b) {x=a,y=b;}
int GetX(){return x;}
int GetY(){return y;}
};
class Circle : public Point
{
protected:
int radius;
public:
Circle(int a=0,int b=0,int r=0){radius=r;}
int getRadius() {return radius;}
};
void main()
{
Circle c(100,150,200);
cout<<"x=

注意几点啊:
(1)、C++语言是大小写区分的。一定要前后一致。
(2)、所有标识符和关键字以及标点都必须是英文字符下打出来的
(3)、最关键的还是要自己学会调试!

1、
#include<iostream.h>
#include<string.h>//#应该为英文字符,你原来的是中文字符
class Person{//你原来的打括号是中文字符
public:
char m_strName[20];
long m_ID;
public:
Person(char*strName,long ID){strcpy(m_strName,strName);m_ID=ID;}//标识符中间不能有空格
/* static*/ long GetID() {return m_ID;}//static函数只能修改static变量,你得m_ID不是static变量
};
void main()
{
Person person1("LiuJun",1101640524);//类定义的person是大写开头的
cout<<"ID="<<person1.GetID()<<'\n';//又出现中文字符"ID=”
//不是static变量,这样调用不知道输出哪个id
}

2、
#include<iostream.h>//#为英文字符
class point
{
protected:
int x,y;
public:
point(int a,int b) {x=a,y=b;}
int GetX(){return x;}
int GetY(){return y;}
};
class Circle : public point//定义的point为小写
{
protected: