如何从c调用C ++代码中的函数 [英] how to call functions in C++ code from c
问题描述
你好,
现在我正在用C ++编写代码。而一些现有的c代码
将调用一些C ++类中的函数。我阅读了SUN网站上介绍的基本
技术。
基本上
1.我们可以添加externC关键字,或
2.使用C ++代码中的对象作为C中的结构。
我的问题是:我们是否必须在c中初始化对象?因为
c中没有构造函数,当我们声明
struct M时,它会调用c ++中的默认构造函数
in c,M是用C ++定义的对象?
网上有没有详细的参考资料?
TIA
Mike
" Mike Qin" < LQ ** @ sce.carleton.ca>在消息新闻中写道:c0 ********** @ driftwood.ccs.carleton.ca ...
我的问题是:我们是否必须初始化对象在c?因为
c中没有构造函数,当我们声明时,它会调用c ++中的默认构造函数吗
你不能使用任何一个非平凡的类C中的构造函数。
" Ron Natalie" < ro*@sensor.com>在消息中写道
news:40 ********************* @ news.newshosting.com。 ..
Mike Qin < LQ ** @ sce.carleton.ca>在消息中写道
news:c0 ********** @ driftwood.ccs.carleton.ca ...我的问题是:我们是否必须初始化对象在c?因为
c中没有构造函数,当我们声明时它会调用c ++中的默认构造函数吗
你不能在C中使用任何具有非平凡构造函数的类。
请原谅我的无知,C中的非平凡构造函数是什么?
Ron Natalie写道:" Mike Qin" < LQ ** @ sce.carleton.ca>在消息新闻中写道:c0 ********** @ driftwood.ccs.carleton.ca ...
我的问题是:我们有没有在c中初始化对象?因为在c中没有构造函数,当我们声明时它会调用c ++中的默认构造函数
你不能使用任何一个非平凡的类C中的构造函数。
或者是一个简单的,或任何成员函数。
Ian
>
Hi there,
Now I''m writing code mainly in C++. And some existing c code
will call some functions which are in a C++ class. I read the basic
techniques introduced from a SUN''s web site.
Basically
1. we can add extern "C" keyword, or
2. use the object in C++ code as struct in C.
My question is: do we have to initialize the object in c? because
there is no constructor in c, will it call a default constructor in c++
when we declare
struct M;
in c, M is an object defined in C++?
Is there any detailed reference available on net?
TIA
Mike
"Mike Qin" <lq**@sce.carleton.ca> wrote in message news:c0**********@driftwood.ccs.carleton.ca...
My question is: do we have to initialize the object in c? because
there is no constructor in c, will it call a default constructor in c++
when we declare
You can not use any class with a non-trivial constructor in C.
"Ron Natalie" <ro*@sensor.com> wrote in message
news:40*********************@news.newshosting.com. ..
"Mike Qin" <lq**@sce.carleton.ca> wrote in message news:c0**********@driftwood.ccs.carleton.ca...My question is: do we have to initialize the object in c? because
there is no constructor in c, will it call a default constructor in c++
when we declare
You can not use any class with a non-trivial constructor in C.
Excuse my ignorance, what is a "non-trivial constructor in C?"
Ron Natalie wrote:"Mike Qin" <lq**@sce.carleton.ca> wrote in message news:c0**********@driftwood.ccs.carleton.ca...My question is: do we have to initialize the object in c? because
there is no constructor in c, will it call a default constructor in c++
when we declare
You can not use any class with a non-trivial constructor in C.
Or a trivial one, or any member functions.
Ian
这篇关于如何从c调用C ++代码中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!