Blogroll

Difference between C and C + +

Saturday, 26 May 2012

1. C is a procedure or function oriented language Whereas a C + + is Object Oriented language.

2. C HAS top down approach Whereas C + + HAS bottom-up approach.

3. In C + + new and delete operators are Used To allocate and free memory object in C malloc () and free () functions are Used For Freeing and allocating memory.

4. In C + + prototype of a function Have To Be Defined Before using it in order Can Be Used C functions without Defining a prototype.

5. Structures of C + + functions in Can Have Them goal structures C Cdn Have only variables
.
6. For I / O C + + and C HAS HAS iostream.h stdio.h.

7. Function overloading is allowed option in C + + functions in C goal does not support overloading.

8. We Have in C to include the struct keyword Before the name of the structure has to declare instance of a structure. In C + + only the structure name is required. Example -:

         
struct employee

        
{

           
int id;

           
char * name;

           
/ / Other variables

        
};

         
/ / Statement to declare variable structure in C

         
struct employee e1;

         
/ / Statement to declare structure variable in C + +

         
employee e1;
main () Does not Automatically add return 0 statement in C. In C + + it provide statement this statement.
/ / In C + + return 0 is added Automatically.

     
int main ()

       
{

             
printf ("Hello How are you");

        
}
/ / In C return 0 Has To Be Manually added.

     
int main ()

       
{

             
printf ("Hello How are you");

             
return 0;

        
}
9. C allows a void * pointer to Be Assigned to point-to-any kind without a cast, Whereas C + + Does not

10. Enumeration constant are always of type int in C, Whereas They Are distinct types in C + + and may differ from That Have size of int.

11.C + + identifiers are not allowed to Contain Two or more consecutive underscores in Any Position. C identifiers are not allowed to start With Two or more consecutive underscores, goal peut 'em In Other positions

12. C allows struct, union, and enum type To Be Declared in function prototypes, Whereas C + + Does not.

No comments:

Post a Comment

 

Most Reading

Tags

Sidebar One