why c++ is not called strictly d super set of c?

Answers were Sorted based on User's Feedback



why c++ is not called strictly d super set of c?..

Answer / astha biswas

there are some key-words like class , new etc which can be
used as identifiers in c. so if we save program in .c using,
new as an identifier, it will not show any error; but if we
save the same program in .cpp, it will show error as new is
an operator in c++.

EX:

#include<stdio.h>
#include<conio.h>
void main()
{
int new;
clrscr();
new=3;
printf("%d",new);
}

if we execute this program in .c, output will be 3.
but if we execute this program in .cpp; then it will show 2
errors.
1. declaration terminated incorrectly.
2. lvalue required.

Is This Answer Correct ?    10 Yes 1 No

why c++ is not called strictly d super set of c?..

Answer / bijayalaxmi behera.

In the strictly mathematical sense,c++ is not strictly super
set of c.Because,there are some programs that are valid c
but not valid c++.One more thing,few ways of writing the
code that has a different meaning in c and c++.

Is This Answer Correct ?    5 Yes 1 No

why c++ is not called strictly d super set of c?..

Answer / subhashree das

there are some operators in c++; which can be used as
identifiers in c. so if we execute the program in .c it will
not show any error, where as if we execute the same program
in .cpp , it will show error.

Is This Answer Correct ?    5 Yes 1 No

Post New Answer

More C++ General Interview Questions

Can static member variables be private?

0 Answers  


Is java a c++?

0 Answers  


How long does it take to get good at leetcode?

0 Answers  


Is c the same as c++?

0 Answers  


Difference between static global and global?

16 Answers   Microsoft, Symphony, Wipro,






how to find the maximum of 10 numbers ?

5 Answers  


Can comments be longer than one line?

0 Answers  


1)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea += sizeof(int); } return 0; } 2)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea ++; } return 0; } The output of this two programs will be different why?

5 Answers  


What is algorithm in c++ programming?

0 Answers  


What is meant by entry controlled loop?

0 Answers   Agilent, ZS Associates,


Write a program to add three numbers in C++ utilizing classes.

0 Answers   TCS,


What is a "Copy Constructor"?

2 Answers  


Categories