Example: https://sjobs.brassring.com/TGWebHost/jobdetails.aspx?jobId=...
At that time mixing C and C++ was trivial, especially because C++ was still quite simple and the C compiler was the target.
But after that things got more complicated. C evolved, several times in fact since that time and the C++ standard evolved as well. Leading to the impression that C and C++ are merely the old and the improved version of C but it is probably much better to think of them as two distinct species that share a common ancestor, where one of the two had some very radical mutations.
Contact Pro IT Recruiting where we know our candidates, Referral bonuses too!
C - ISO/IEC 9899:2011
C++ - ISO/IEC 14882:2014
Also, much C code is still valid C++. Sure, you can write code that isn't, but I would guess (pulls a number out of nowhere) that 90% of the valid C code is also valid C++.
That makes them languages that have separate standards, but not completely independent standards, that share a whole lot of source code. That's something less than fully separate in my book.
$ cat foobar.c
#include <stdio.h>
struct foo {
int x;
int y;
};
int foobar(struct foo *f)
{
return f->x + f->y;
}
int
main(int argc, char *argv[]) {
(void)argc; (void)argv;
printf("%d\n", foobar(&(struct foo){10, 20}));
return 0;
}
$ gcc -Wall -Wcast-align -Wextra -pedantic -std=c99 foobar.c -o foobar && ./foobar
30
$ g++ -Wall -Wcast-align -Wextra -pedantic foobar.c -o foobar && ./foobar
foobar.c: In function ‘int main(int, char**)’:
foobar.c:17: warning: ISO C++ forbids compound-literals
foobar.c:17: warning: taking address of temporary
30
$ # taking address of temporary means that it's undefined behavior
[0] https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.htmlBetter examples (of actually useful things) would be things like designated initializers, struct literals, declaring array lengths in args using static, etc.
int *x = malloc(sizeof(int));struct Foo { int virtual; };
[1] https://github.com/spc476/SPCDNS
[2] https://github.com/spc476/SPCDNS/blob/ca5052c3d0c3252071a18e...
[3] I am NOT a fan of C++.
[4] But I had to anyway, but I used the C pre-processor to rename the field.
C99 native complex numbers