---
title: "C versus C++ and C++ features"
subject: "Object Oriented Programming"
chapter: 2
key: "semester_3/object_oriented_programming:c-vs-cpp-features"
source: https://www.bctengineer.com/q/semester_3/object_oriented_programming/c-vs-cpp-features
site: BCT Engineering
---

# C versus C++ and C++ features

Object Oriented Programming · Chapter 2: Introduction to C++

- Asked in: 2068 Baisakh, 5+5 marks
- Video: [How different are C and C++? Can I still say C/C++?](https://www.youtube.com/watch?v=Kq8m980JEeg) — Jacob Sorber
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_3/object_oriented_programming/c-vs-cpp-features
- Whole chapter: https://www.bctengineer.com/md/semester_3/object_oriented_programming/chapter-2

## Question

Compare C and C++. Write down different features of C++ with example for each.

## Short answer

C is procedural; C++ adds object-oriented capabilities. Key C++ features: classes (class Box { int side; }), overloading (int add(...), float add(...)), templates (template<class T> T max(T,T)), inheritance, exceptions, references, and new/delete for dynamic memory.

## Answer

#### Comparison of C and C++

| Point | C | C++ |
|---|---|---|
| Paradigm | Procedural | Procedural and object oriented |
| Basic unit | Function | Class / object |
| Data hiding | Not possible | Possible (`private`, `protected`) |
| Overloading | Not supported | Function and operator overloading |
| Memory | `malloc()` / `free()` | `new` / `delete` |
| I/O | `printf()` / `scanf()` | `cout` / `cin` |
| References | No (pointers only) | Reference variables |
| Inheritance and polymorphism | No | Yes |
| Exceptions, templates, namespaces | No | Yes |
| Inline functions | Not in original C | Supported |

#### Features of C++ with examples

1. **Classes and objects**
```cpp
class Box { public: int side; };
Box b; b.side = 5;
```
2. **Encapsulation and data hiding**
```cpp
class A { private: int x; public: void set(int v) { x = v; } };
```
3. **Inheritance**
```cpp
class Student : public Person { };
```
4. **Function overloading**
```cpp
int add(int a, int b);  float add(float a, float b);
```
5. **Operator overloading**
```cpp
Complex operator+(Complex c);
```
6. **Polymorphism by virtual functions**
```cpp
class Shape { public: virtual void draw(); };
```
7. **Templates**
```cpp
template <class T> T maxOf(T a, T b) { return a > b ? a : b; }
```
8. **Exception handling**
```cpp
try { if (d == 0) throw 0; } catch (int e) { cout << "Divide by zero"; }
```
9. **Reference variables and inline functions**
```cpp
void swap(int &a, int &b);   inline int sq(int x) { return x * x; }
```
10. **Dynamic memory**
```cpp
int *p = new int[10];  delete[] p;
```

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which is true about paradigm?
   A. C is OO; C++ procedural
   B. C is procedural; C++ is procedural and object oriented
   C. Both OO only
   D. Both procedural only
   Answer: B. Table row. (Key point: Paradigm)

2. Dynamic memory in C and C++ respectively?
   A. new/delete; malloc()/free()
   B. Both malloc
   C. malloc()/free(); new/delete
   D. Both new
   Answer: C. Table row. (Key point: Memory)

3. Does C support function overloading?
   A. Yes; C++ does not
   B. Both do not
   C. Both do
   D. No; C++ does
   Answer: D. C lacks overloading. (Key point: Overloading)

4. Which declaration uses reference parameters?
   A. void swap(int &a, int &b);
   B. void swap(int a, int b);
   C. void swap(int *a);
   D. inline void swap();
   Answer: A. & marks reference. (Key point: Reference example)

## Related in Object Oriented Programming

- [Data abstraction versus encapsulation](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Adata-abstraction-encapsulation) — Object Oriented Programming, chapter 1

## Related in other subjects

- [Browser features; POP, SMTP, IMAP comparison](https://www.bctengineer.com/question.md?key=semester_8%2Finternet_and_intranet%3Apop-smtp-imap-compare) — Internet and Intranet, chapter 3, asked 2×
- [MBI features; open vs closed loop compared](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Ambi-features-open-closed) — Instrumentation II, chapter 1
- [Macadam versus Telford construction](https://www.bctengineer.com/question.md?key=semester_6%2Ftransportation_engineering_i%3Amacadam-vs-telford) — Transportation Engineering I, chapter 1, asked 2×
- [UMS features, VoIP in UMS, IP clearing house](https://www.bctengineer.com/question.md?key=semester_8%2Finternet_and_intranet%3Aums-voip-ipch) — Internet and Intranet, chapter 7
