相关疑难解决方法(0)

如何从C调用C++方法?

我有一个C++类,我正在用一些C文件编译它.

我想调用一个用C++定义的函数,实际上是在C++类中,所以我该怎么做?

以下声明显示我在说什么:可能存在语法错误:

serial_comm.cpp

class MyClass {
    void sendCommandToSerialDevice(int Command, int Parameters, int DeviceId) {
         //some codes that write to serial port.
    }
}
Run Code Online (Sandbox Code Playgroud)

external.c

int main(int argc, char ** argv) {
    //what am I going to write here?
}
Run Code Online (Sandbox Code Playgroud)

c c++ class extern

9
推荐指数
2
解决办法
2万
查看次数

标签 统计

c ×1

c++ ×1

class ×1

extern ×1