VS2019的多文件编译方法
2019-07-08 16:29
656 查看
方法:
1.打开VS2019建立一个空项目
2.里面都是空的,在对应目录下新建自己的头文件、源文件
3.编辑自己新建的文件
4.运行
代码(6-3对象数组应用举例的代码):
[code]//main.cpp #include<iostream> #include"Point.h" using namespace std; int main() { cout << "Entering main..." << endl; Point a[2]; for (int i = 0; i < 2; i++) a[i].move(i + 10, i + 20); cout << "Exiting main..." << endl; return 0; } //Point.h #ifndef _POINT_H #define _POINT_H class Point { public: Point(); Point(int x, int y); ~Point(); void move(int newX, int newY); int getX() const { return x; } int getY() const { return y; } static void showCount(); //静态成员函数 private: int x, y; //私有成员 }; #endif//_POINT_H //Point.cpp #include<iostream> #include"Point.h" using namespace std; Point::Point() :x(0), y(0) { cout << "Default Constructor called." << endl; } Point::Point(int x, int y) : x(x), y(y) { cout << "Constructor called." << endl; } Point::~Point() { cout << "Destructor called." << endl; }
相关文章推荐
- Matlab中调用VS编译的exe文件并传递变量 的方法
- 运行VS2013编译成功后出现:无法启动程序“.exe” 系统找不到指定文件的问题的解决方法
- VS项目中非stdafx.h文件目录包含stdafx.h的编译失败的解决方法
- 在WIN10系统下运行VS2013编译成功后出现:无法启动程序“.exe” 系统找不到指定文件的问题的解决方法
- VS 2005 编译的程序不能运行的几个解决方法
- VS.net VSS时,编译报错:未能向文件XXX 写入命令行。对路径 "XXX"的访问被拒绝。
- 通过预编译头文件的方法来提高c++builder的编译速度
- VS.net配合VSS时,编译报错:未能向文件“.csproj.FileListAbsolute.txt”写入命令行 对路径 的访问被拒绝。
- 用gcc编译生成动态链接库*.so文件的方法
- 反编译apk文件,得到其源代码的方法!
- 查找文件夹中的所有文件及子文件夹的方法,附源程序,VC7.1下编译运行通过
- 我给vs2005类文件全部加上namespace后,报aspx.GetHashCode() 没有找到合适的方法来重写
- 让VC不再编译帮助文件的方法
- 把Java程序编译成exe文件的2个方法
- Java中class文件编译成exe文件的几种方法
- vs下无法打开包括文件:“cutil_inline.h”的解决方法
- 用gcc编译生成动态链接库*.so文件的方法
- 关于Eclipse无法重新编译java文件的处理方法之一
- 用gcc编译生成动态链接库*.so文件的方法
- 查找文件夹中的所有文件及子文件夹的方法,附源程序,VC7.1下编译运行通过