先创建一个子目录TestStruct,在该目录下,生成一个.h 和两个.cpp文件链接编译,结构如下:
1. 创建出TestStruct目录
2. 在该目录下创建TestStruct.h和TestStruct.cpp,TestStruct1.cpp文件
TestStruct.h
#ifndef LEARN01_TESTSTRUCT_H
#define LEARN01_TESTSTRUCT_H
struct Polar {
int a;
int b;
};
int Add(Polar polar);
#endif //LEARN01_TESTSTRUCT_H
TestStruct.cpp
#include <iostream>
#include "TestStruct.h"
using namespace std;
int main(){
Polar polar = {1, 2};
cout<<"param1:"<<polar.a<<endl;
cout<<"param2:"<<polar.b<<endl;
int b = Add(polar);
cout<<b<<endl;
return 0;
}
TestStrcut1.cpp
#include "T