Commit 48df3400 authored by Administrator's avatar Administrator
Browse files

add cpp and header separation sample

parent 6628424b
...@@ -7,5 +7,8 @@ ...@@ -7,5 +7,8 @@
# Include all cpp file under all folder # Include all cpp file under all folder
!**/*.cpp !**/*.cpp
# Include all h file under all folder
!**/*.h
# Include .gitignore itself # Include .gitignore itself
!.gitignore !.gitignore
#include <iostream>
#include "Setup.h"
using namespace std;
// 设定分辨率
void Setup::setResolution() {
this->resolution_width = 1920; // 从设定处取得
this->resolution_height = 1080; // 从设定处取得
};
// 取得分辨率
int Setup::getResolution() {
// 水平分辨率 X 垂直分辨率
return this->resolution_width * this->resolution_height;
};
\ No newline at end of file
#pragma once // 防止头文件被重复包含
#include <iostream>
using namespace std;
// 用于存放各类设置
class Setup {
private:
// 水平分辨率
int resolution_width;
// 垂直分辨率
int resolution_height;
public:
// 设定分辨率
void setResolution();
// 取得分辨率
int getResolution();
};
\ No newline at end of file
#include <iostream>
#include "common/Setup.h"
int main() {
Setup s;
s.setResolution();
cout << "Resolution: "<< s.getResolution() << endl;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment