473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C and C++ are interoperable languages? True or Not True?

Hi all,

I've just gone thru a so called e-learning course on the web and I
found that one of the test question is interesting.

Here is the question:

What is the relationship between the C and C++ programming languages?

1. They are both object-oriented programming languages
2. They are interoperable languages
3. C++ changes the syntax used in C
4. C++ evolved from C

I select the choice number 4 as my answer. (You are allowed to select
more than one choice if you think they are corrected)

But when I look at the model answer, it says that both choice 2 and 4
are correct. Well, I'm pretty sure choice number 4 is correct but I'm
don't think choice number 2 is. So I called up the Online Mentor and
chat with him for half an hour but the expert on the other side cannot
give me a satisfy answer.

Here is the explanation given by the mentor.
1. C is a subset of C++ (I agree)
2. Program written in C will work in a C++ environment (I agree)
3. Program written in C++ without using any C++ feature will work in a
C environment (I agree, but I would rather call it a c program instead)
4. So they are interoperable. (I don't get it)
Anybody can enlighten me please.

Rgds,
Chip Ling

Jul 22 '05 #1
6 1388
Chip wrote:
Hi all,

I've just gone thru a so called e-learning course on the web and I
found that one of the test question is interesting.

Here is the question:

What is the relationship between the C and C++ programming languages?

1. They are both object-oriented programming languages
No.
2. They are interoperable languages
No.

3. C++ changes the syntax used in C
No.

4. C++ evolved from C
Yes!

I select the choice number 4 as my answer. (You are allowed to select
more than one choice if you think they are corrected)

But when I look at the model answer, it says that both choice 2 and 4
are correct. Well, I'm pretty sure choice number 4 is correct but I'm
don't think choice number 2 is. So I called up the Online Mentor and
chat with him for half an hour but the expert on the other side cannot
give me a satisfy answer.

Here is the explanation given by the mentor.
1. C is a subset of C++ (I agree)

No. C90 with few differences was a subset of C++. However the most
recent standard of C is C99 and there are many differences.

2. Program written in C will work in a C++ environment (I agree)

No (not necessarily).

3. Program written in C++ without using any C++ feature will work in a
C environment (I agree, but I would rather call it a c program instead)


More accurately, a C++ program which is written by using the C subset
C90) of C++, is also a valid C program (it compiles).
However under a C99 compiler the source code may have different meanings
(for example the largest unsigned integral built in type in C++ is
unsigned long, while in C99 is unsigned long long).


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #2

"Chip" <ch*******@yahoo.ca> wrote in message
Hi all,

I've just gone thru a so called e-learning course on the web and I
found that one of the test question is interesting.

Here is the question:

What is the relationship between the C and C++ programming languages?

1. They are both object-oriented programming languages
2. They are interoperable languages
3. C++ changes the syntax used in C
4. C++ evolved from C

I select the choice number 4 as my answer. (You are allowed to select
more than one choice if you think they are corrected)

But when I look at the model answer, it says that both choice 2 and 4
are correct. Well, I'm pretty sure choice number 4 is correct but I'm
don't think choice number 2 is. So I called up the Online Mentor and
chat with him for half an hour but the expert on the other side cannot
give me a satisfy answer.

Here is the explanation given by the mentor.
1. C is a subset of C++ (I agree)
Not exactly. That would mean every C program is a C++ program which isn't
the case actually.

int main(void)
{
int class; // Valid C++ ??
}
2. Program written in C will work in a C++ environment (I agree)


Not true. Read above.

Sharad
Jul 22 '05 #3
"Chip" <ch*******@yahoo.ca> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I've just gone thru a so called e-learning course on the web and I
found that one of the test question is interesting.

Here is the question:

What is the relationship between the C and C++ programming languages?

1. They are both object-oriented programming languages
Only C++ has built-in support for the object-oriented programming
paradigm. You can do OOP in C, but it is cumbersome.

2. They are interoperable languages
They have a large common subset, which makes them largely interoperable
in practice. There is a number of incompatibilities, but committees who
define both languages collaborate closely to ensure good
interoperability.
Based on this, I'd be very tempted to say yes.

3. C++ changes the syntax used in C
It extends it, but doesn't really change it.

4. C++ evolved from C
Yes, it was derived from C.

I select the choice number 4 as my answer. (You are allowed to select
more than one choice if you think they are corrected)

But when I look at the model answer, it says that both choice 2 and 4
are correct. Well, I'm pretty sure choice number 4 is correct but I'm
don't think choice number 2 is. So I called up the Online Mentor and
chat with him for half an hour but the expert on the other side cannot
give me a satisfy answer.

Here is the explanation given by the mentor.
1. C is a subset of C++ (I agree)
2. Program written in C will work in a C++ environment (I agree)
3. Program written in C++ without using any C++ feature will work in a
C environment (I agree, but I would rather call it a c program instead)
4. So they are interoperable. (I don't get it)
Anybody can enlighten me please.


Can you name 2 languages that are more interoperable than C and C++ ?
I do not think the question is great an unequivocal.
But I wouldn't say that the 'correct' answer is wrong.
Regards,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Jul 22 '05 #4
> However under a C99 compiler the source code may have different meanings
(for example the largest unsigned integral built in type in C++ is
unsigned long, while in C99 is unsigned long long).


slightly OT, but slightly amusing as well
Have you ever tried to compile the following with gcc?

int main()
{
long l1;
long long l2;
long long long l3;

return 0;
}

The first two declarations work fine, but the third one gives the error
message:

longlonglong.c: In function `main':
longlonglong.c:5: error: `long long long' is too long for GCC

I was amused.
Jul 22 '05 #5
Jon Wilson wrote:
However under a C99 compiler the source code may have different
meanings (for example the largest unsigned integral built in type in
C++ is unsigned long, while in C99 is unsigned long long).

slightly OT, but slightly amusing as well
Have you ever tried to compile the following with gcc?

int main()
{
long l1;
long long l2;
long long long l3;

return 0;
}

The first two declarations work fine, but the third one gives the error
message:

longlonglong.c: In function `main':
longlonglong.c:5: error: `long long long' is too long for GCC

I was amused.


Yes you are right, this one is really good! :-))


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #6
Chip wrote:
I've just gone thru a so called e-learning course on the web
and I found that one of the test question is interesting.

Here is the question:

What is the relationship between the C and C++ programming languages?

1. They are both object-oriented programming languages
No. C is *not* an object oriented programming language
because it does not support inheitance.
You can force C compilers to "adopt" derived types
through a pointer using an explicit cast
and you can mimick run-time polymorphism by including
a pointer to a virtual function table in the base type
but this is tedious, unreliable and may not be prortable everywhere.
2. They are interoperable languages
No. Interoperability is determined by the implementations
and *not* by the standard language definitions.
There isn't even a guarantee that
code emitted from two different implementations of the same language
are interoperable.
But, in fact, a high degree of interoperability
among different implementations exists
event for different computer programming languages
partly because they all conform
to the same Application Binary Interface (ABI) --
usually the C ABI -- for any given platform
(machine architecture and operating system combination).
3. C++ changes the syntax used in C
No.
4. C++ evolved from C
No. C++ *extends* C.
I select the choice number 4 as my answer.
(You are allowed to select more than one choice
if you think they are correct.) But when I look at the model answer,
it says that both choice 2 and 4 are correct.
Well, I'm pretty sure choice number 4 is correct
but I don't think choice number 2 is [correct].
Code emitted by C and C++ compilers may be interoperable
but this has almost nothing to do with the language
except that the C++ extern "C" feature *helps* with linkage.
But, even if, you can link C an C++ code together,
there is no guarantee that they use compatible
argument passing and value return conventions.
So I called up the Online Mentor and chat with him for half an hour
but the expert on the other side cannot give me a satisfy answer.

Here is the explanation given by the mentor.
1. C is a subset of C++. (I agree).
Mostly correct.
2. Program written in C will work in a C++ environment. (I agree.)
Usually, but there are important exceptions.
3. Program written in C++ without using any C++ [extensions] will work in a
C environment. (I agree, but I would rather call it a C program instead.)
4. So they are interoperable. (I don't get it)
Anybody can enlighten me please.


The term "interoperable" implies more than compatible linkage.
If your C and C++ code are interoperable,
it is because your C and C++ compilers also conform to the same ABI.

I used Google

http://www.google.com/

to search for

+"C ABI" +"interoperability"

and I found lots of stuff.
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Christian Seberino | last post by:
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python? Python's design is godly. I'm wondering if Ruby's is godly too. I've heard it has solid OOP design but then...
39
by: Steven T. Hatton | last post by:
I came across this while looking for information on C++ and CORBA: http://www.zeroc.com/ice.html. It got me to wondering why I need two different languages in order to write distributed computing...
4
by: kk | last post by:
SAS/C INTEROPERABLE WITH IBM C/C++, WHAT ARE THE DIFFERENCES, DOES SAS/C PRODUCE SAME TYPE PERL EXTENSIONS AND INTEROPERATE WITH C MODULES THAT RESULT FROM COMPILATIONS USING LE ? IF I AM RUNNING...
1
by: Torben Laursen | last post by:
Hi I have a dll that is beeing called by C++, VBA, Java and C# One of my customers does not like that I have bool in the argument list of some of the exported functions so I want to replace all my...
40
by: apprentice | last post by:
Hello, I'm writing an class library that I imagine people from different countries might be interested in using, so I'm considering what needs to be provided to support foreign languages,...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
28
by: sturlamolden | last post by:
On Monday Microsoft announced a new runtime for dynamic languages, which they call "DLR". It sits on top of the conventional .NET runtime (CLR) and provides services for dynamically typed...
14
by: Summercool | last post by:
The meaning of a = b in object oriented languages. ==================================================== I just want to confirm that in OOP, if a is an object, then b = a is only copying the...
151
by: istillshine | last post by:
There are many languages around: C++, JAVA, PASCAL, and so on. I tried to learn C++ and JAVA, but ended up criticizing them. Is it because C was my first programming language? I like C...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.