C++中有两个文件:xt8-4.h和xt8-4.cpp 具体代码见问题补充,在VC++6.0中如何实现运行 我希望具体的步骤
//xt8-4-1.cpp(main.cpp)#include<iostream>usingnamespacestd;#include"xt8-4.h"intmain()...
//xt8-4-1.cpp(main.cpp)
#include <iostream>
using namespace std;
#include "xt8-4.h"
int main()
{Student stud;
stud.set_value();
stud.display();
return 0;
}
//xt8-4.h(student.h)
class Student
{ public:
void display( );
void set_value();
private:
int num;
char name[20];
char sex ;
}; 展开
#include <iostream>
using namespace std;
#include "xt8-4.h"
int main()
{Student stud;
stud.set_value();
stud.display();
return 0;
}
//xt8-4.h(student.h)
class Student
{ public:
void display( );
void set_value();
private:
int num;
char name[20];
char sex ;
}; 展开
1个回答
展开全部
#include <iostream.h>
// using namespace std; // MS VC++ comment out the line
#include "point.h"
#include "point.cpp"
void main(){
Point A(4,5);
cout<<"Point A,"<<A.getx()<<","<<A.gety();
A.getc();
Point B(A);
cout<<"Point B,"<<B.getx()<<","<<B.gety();
Point::getc();
}
--------------------------------------------
// point.cpp
int Point::count=0;
Point::Point(Point &p){
X=p.X;Y=p.Y;count++;}
----------------------------------
// point.h
class Point{
public:Point(int xx=0,int yy=0)
Point(Point &p);
~Point()
int getx()
int gety()
static void getc()
private:int X,Y;
static int count;
};
---------------------------
MS VC++ 编译通过。
// using namespace std; // MS VC++ comment out the line
#include "point.h"
#include "point.cpp"
void main(){
Point A(4,5);
cout<<"Point A,"<<A.getx()<<","<<A.gety();
A.getc();
Point B(A);
cout<<"Point B,"<<B.getx()<<","<<B.gety();
Point::getc();
}
--------------------------------------------
// point.cpp
int Point::count=0;
Point::Point(Point &p){
X=p.X;Y=p.Y;count++;}
----------------------------------
// point.h
class Point{
public:Point(int xx=0,int yy=0)
Point(Point &p);
~Point()
int getx()
int gety()
static void getc()
private:int X,Y;
static int count;
};
---------------------------
MS VC++ 编译通过。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询