what are the features of c which are not available in c++ ???

c is not an object oriented programming language.

what are the features of c which are not available in c++ ???

There are none. some may be implented in C++ a little differently, but they are all there nontheless. For example, c++ requires typecasting when assigning a void* object to some other kind of pointer, C does not require that. That is a difference in implenentation, not a feature that C has but C++ does not.

>c is not an object oriented programming language
that is a feature of c++ that is not in c. The question was just the opposite.

true I guess I just looked at the title and added some input, but I have also heard of something called objective c which is a way of using oop in c.

Objective-C is a very "thin" layer on top of C. Objective-C is a strict superset of C. That is, it is possible to compile any C program with an Objective-C compiler (this cannot be said of C++). Objective-C derives its syntax from both C and Smalltalk. Most of the syntax (including preprocessing, expressions, function declarations and function calls) is inherited from C, while the syntax for object-oriented features was created to enable Smalltalk-style message passing.

http://en.wikipedia.org/wiki/Objective-C

> what are the features of c which are not available in c++ ???
C++ is a semantic superset of C. That is, everything you can do in C you can also do in C++.

C++ is NOT a syntactic superset of C. That is, you can't take every C program and compile it using C++ and expect identical functionality and no error messages (for all the reasons in the link Dave posted).

> what are the features of c which are not available in c++ ???
C++ is a semantic superset of C. That is, everything you can do in C you can also do in C++.

Can we say that for C also? i.e C is semantic superset of C++. Everything you can do in C++ you can also do in C.

Everything you can do in C++ you can also do in C.

Are you sure? You can create a class in C++. Can you create a class in C also?

Can we say that for C also? i.e C is semantic superset of C++. Everything you can do in C++ you can also do in C.

Maybe u r confusing between superset and subset.

a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
b = {1, 2, 3}

Here b is the subset of a .
Here a is the superset of b.

In the same way C++, the one with more functionality and inheriting almost all the syntax from C and adding on its own is a superset of C.

Are you sure? You can create a class in C++. Can you create a class in C also?

You can create a class in C, but the language does not provide the syntax in the way that you are implying/asking.

You can create a class in C, but the language does not provide the syntax in the way that you are implying/asking.

oh. How do you do that?

Create a struct or perhaps even a built-in type. Add functions to handle the type you've created.

Consider FILE or time_t .

maybe something like below, although this isn't exactly like a c++ class, but close. There is nothing to prevent the program from calling function bar() directly from anywhere in the program, while that is possible in a c++ program only if bar() were a static method of the class.

Note that mystruct will not compile with a C compiler if member function pointer is a function name instead of a pointer. (at least with Dev-C++)

struct mystruct
{
   int x,y;
   int (*foo)(struct mystruct* this);
};
int bar(struct mystruct* this);

int bar(struct mystruct* this)
{
   return 0;
}

int main(int argc, char *argv[])
{
  struct mystruct ms;
  ms.foo = bar;
  system("PAUSE");	
  return 0;
}

Err...

@Mr.Ancient Dragon

I was advised here that the call system ("PAUSE"); calls the operating system procedure which is not very advisable since ther is a switch is the context.

Are there any exceptions to this rule since u have used that stmt in ur code ? Just curious ...

Err...

@Mr.Ancient Dragon

I was advised here that the call system ("PAUSE"); calls the operating system procedure which is not very advisable since ther is a switch is the context.

Are there any exceptions to this rule since u have used that stmt in ur code ? Just curious ...

Dev-C++ IDE generated that function when I created the C project, I just didn't bother to change it. The only time I use it is in simple example or test programs, and it doesn't really matter in those cases.

but you are right; there are more efficient and safer ways to accomplish the same thing. I don't ever use system() function in the commercial programs I write at work.

Phew that is a relief, i was about to get convinced that there is something wrong with my concepts.

Anyways thanks for saying that in the end i was right.

C has an extended wide character stream library thanks to C AMD1 (since 1995).
C has Variable Length Arrays.
C has restrict pointers.
C has imaginary and complex numbers (C++ has a standard library for complex numbers).
C has flexible arrays.
C has the long long data type.
C has a much more detailed implementation constraints on number representations, integer division.
C has compound literals and hexadecimal floating point constants.
C has designated initializers.
C has extended integer types & functions in <inttypes.h> and <stdint.h>, additional floating-point characteristics (in <float.h>) and environmental features in <fenv.h>
C has macros with a variable number of arguments.
C has snprintf
C has __func__ and va_copy

C allows (AFAIK) to alias several members of the same union (results are unspecified)
In general, C has much more specific rules about representation of objects, trap representations, and the result of operators.

So, please, don't say that C++ is a superset of C.
Especially, for representations... You can't easily write a C99 frontend using a C++ backend(I know, the opposite is more common).

commented: Good Point. +3

c++ has all those things too and that makes C++ a superset of C although there are a few things in C that are implemented slightly differently in C++. And noone implied that you can write a C front-end for C++, that implies c++ would be a subset of C, not the other way around.

It really depends on the point of view or the angle from which u are judging the problem or the argument.

C++ can be used to write procedure oriented as well as Object oriented in an easy manner so from this point of view C is subset of C++.
I know there is also object oriented C but thats not very widely used as ppl very much prefer to migrate to C++ for OOP rather than useing Objective C.

Does C support Operator Overloading, Funciton overloading, Function overriding, Virtual funcitions, etc. etc.

I hope u get the drift.

since C existed long before C++, that makes C++ a superset. C++ intereted stuff from C, not the other way around. You inhereted certain features from your mother and dad, they didn't inherit them from you.

Yes but the newer generation is always much more enhanced, better than the older generation, and has all the features of the older generation and much more.

SO it depends on the way u look at things, if inheritance wise then as we inherit from our parents we are the subset but if u go feature and functionality wise then its C++ which holds the fort.

But opinions can vary.
Didnt mean to contradict u, jsut expressing the logical.

Bye.

>>Didnt mean to contradict u, jsut expressing the logical.

not a problem. Unlike some people I am wrong sometimes. If I were perfect then I would probably be ruler of this planet :cheesy:

Thanks a lot for understanding, i wouldn't want to upset a senior member with my postings. ;)

>>..: Its the ignorance of the youth that hurts the world :..

but its the spirit and enthusiasm of youth that keeps it going:)

Yeah right, thats an old Japanese saying and is probably right considering the way things currently are shaping up in this world. Kids with no respect for their nation, no respect for elders and so on.

But yes maybe u are right, its the spirit and enthusiasm of some young ppl that makes the world go round.

PS: Mr. Dragon, u really are observant.

c++ has all those things too and that makes C++ a superset of C although there are a few things in C that are implemented slightly differently in C++.

Did you read my post?
All what I listed (except complex numbers) are NOT available in C++.

Y is a superset of X means that for any x in X, x is also in Y

The list I gave is a list of x that are in C but are not in C++
Thus C++ is not a superset of C

You can deem that C++ is a superset of C89, but NOT of C99

And noone implied that you can write a C front-end for C++, that implies c++ would be a subset of C, not the other way around.

False!

The fact that you can write a front-end that translates language X (C for example) to language Y (C++ for example), proves, that functionally Y is as powerful as (or more powerful) than X.
In practice, all programming languages are functionally identical (they are turing-universal).... But, when the translation is very very inefficient, we can deem that Y is more powerful than X.

Functionally C89 and C++ are equivalent (even though, there are a lot of things that are much more convenient to do in C than in C++).
It means that you can write both an *efficient* front-end that converts C++ to C89 or C89 to C++.

C99 is functionally superior to C++, which means that you can easily write an *efficient* and portable front-end that converts C++ code to C99, but you can't write an efficient portable front-end that converts C99 code to C++ code.


I think that the fact that C++ was originally implemented as an efficient C front end confused you... It only proves that, functionally, C++ is as good (or less goot) than C89.
The fact that C++ is (at least functionally) a superset of C89, proves, with the previous sentence, that C++ and C89 are functionally equivalent.

But, for example, make the hypotesis that C++ has an efficient front-end converting C++ code to language X code, but that language X can't be efficiently converted to C++... It would prove that C++ is functionally less powerful than language X... If I admit your statement, it would prove that C++ is functionally more powerful than language X.
Your statement is obviously wrong.

Software development nowadays is all about correct and efficient practices which makes the life of programmer easier for him to code as well as to maintain the code. Todays software development is more about effiecient Object Oriented Practices and following the UML standards to deliver quality and bug free software.

C was originally intended for developing Operating systems and its main asset was its speed considering the amout of memory old computers had. Today seeing the fast drop in dollar / MB of memory its more expected from a language to make the coding and maintenance easier for the programmer ie the language that has solid OO features.

All the above talk was to clear the point that it all depends on the subject matter under consideration. You would next talk about implementing or writing Assembly front end in Machine code and go out to tell that Assembly is the subset of Machine Code. This though is true it also implies that Machine code is the superset of each and every language present today.

I dont think the original poster wanted a C v/s C++ battle for pointing out to him that C++ front end can be easily implemented in C but rather which language is better for developing applications and which language the software community nowadays goes with.

But seeing from ur profile that u are an Assembly programmer, ur love for C is well understood but the point here is that it all depends on the original posters view point.

But still ALL PEACE.

>>C99 is functionally superior to C++,

probably because c++ standards predate C99. It will probably catch up the next time it is updated. If it doesn't then it only means c++ is NO LONGER a subset of C -- they then become two distinctly different languages.

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.