hi guys i am newbie in c/c++ staff and friend of mine told me that you can mix c/c++ and i thought it's cool but i want to see how it's work so please help.. if you have any simple example will appreciate ..thanks
caba992
0
Newbie Poster
Recommended Answers
Jump to PostA C++ compiler will happily compile the following code.
#include <iostream> #include "stdio.h" int main() { std::cout << "Hello "; printf("world"); return 0; }
C++ is (almost) a superset of C. If it's valid C code, it's valid C++. The only time one has to be careful …
Jump to PostAlso, remember that although most C headers are now "C++ safe", if you want to link a C function of your own to C++ code, you need to declare and/or define it as a "C" function. Example:
extern "C" void myCfunction(int arg); // Declaration extern "C" void …
Jump to PostC does not have classes, per se. However, it does have structs, which are something like C++ classes, although all members and functions are public by default. So, you can use a C struct as an element of a C++ class (I've done than upon occasion).
All 9 Replies
Moschops
683
Practically a Master Poster
Featured Poster
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
caba992
0
Newbie Poster
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
Moschops
683
Practically a Master Poster
Featured Poster
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
Moschops
683
Practically a Master Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.