demo记录
1 在C工程里新建test.cpp和test.h文件 并添加到工程
test.h中添加类定义
#ifndef TEST_H
#define TEST_H
class CTest
{
public:
CTest();
char a;
};
#endif
test.c中方法定义
#include "test.h"
CTest::CTest()
{
a=1;
}
2 在main.c中添加 include "test.h" 头文件
void fun()
{
CTest mCtest;
mCtest.a=2;
}
3 编译通过
注意点1:main.c需要将文件属性设定为c++,否则编译出错
注意点1: 如果在main.c中用到C的语法 需要用extern "C" 进行定义