diff --git a/docs/day-01/difference.md b/docs/day-01/difference.md new file mode 100644 index 000000000..70af46f30 --- /dev/null +++ b/docs/day-01/difference.md @@ -0,0 +1,114 @@ +--- +sidebar_position: 2 +title: "History of C++" +description: "Learn about the history of C++, its key features, and how it has evolved over time." +sidebar_label: "History of C++" +slug: /history-of-cpp +--- + +## Difference Between C and C++ + +(1) C + +1. Dennis Ritchie developed the C programming language between 1969 and 1973 at AT&T Bell Labs. +2. C lacks polymorphism, encapsulation, and inheritance, meaning it does not support object-oriented programming. +3. C is largely a subset of C++. +4. The number of keywords in C varies by version: + * C90: 32 + * C99: 37 + * C11: 44 + * C23: 59 +5. C supports procedural programming for code development. +6. In C, data and functions are separated due to its procedural programming nature. +7. C does not support information hiding. +8. Built-in data types are supported in C. +9. C is a function-driven language because it is procedural. +10. C does not support function and operator overloading. +11. C is driven by functions. +12. Functions in C are not defined within structures. +13. C does not have namespace features. +14. The standard IO header in C is stdio.h. +15. C does not support reference variables. +16. Virtual and friend functions are not supported in C. +17. C does not support inheritance. +18. C focuses on methods or processes rather than data. +19. C provides malloc() and calloc() for dynamic memory allocation, and free() for memory deallocation. +20. C does not directly support exception handling. +21. The functions scanf() and printf() are used for input and output in C. +22. C structures do not have access modifiers. +23. There is no strict type checking in C. +24. C does not support overloading. +25. Type punning with unions is allowed in C99 and later. +26. Named initializers can appear out of order. +27. The file extension for C files is ".c". +28. C supports meta-programming through macros and _Generic(). +29. C90 has 32 keywords. + + +(2) C++ + +1. Bjarne Stroustrup developed C++ in 1979. +2. C++ includes polymorphism, encapsulation, and inheritance, making it an object-oriented language. +3. C++ is essentially a superset of C. +4. The number of keywords in C++ varies by version: + * C++98: 63 + * C++11: 73 + * C++17: 73 + * C++20: 81 +5. C++ is considered a hybrid language because it supports both procedural and object-oriented programming paradigms. +6. In C++, data and functions are encapsulated within objects. +7. Encapsulation in C++ hides data to ensure proper usage of data structures and operators. +8. C++ supports both built-in and user-defined data types. +9. C++ is object-driven due to its object-oriented programming nature. +10. C++ supports both function and operator overloading. +11. C++ is driven by objects. +12. Functions can be included within structures in C++. +13. C++ uses namespaces to prevent name conflicts. +14. The standard input/output header in C++ is iostream.h. +15. C++ supports reference variables. +16. C++ supports virtual and friend functions. +17. Inheritance is supported in C++. +18. C++ prioritizes data over methods or procedures. +19. C++ uses the new operator for memory allocation and the delete operator for memory deallocation. +20. Exception handling is a feature of C++. +21. The cin and cout functions are used for input and output in C++. +22. C++ structures include access modifiers. +23. C++ enforces strict type checking, causing many programs that compile in C to produce warnings or errors in C++. +24. C++ supports overloading. +25. Type punning with unions is undefined behavior in C++, except in specific cases. +26. Named initializers in C++ must match the struct's data layout. +27. C++ file extensions include ".cpp", ".c++", ".cc", and ".cxx". +28. Meta-programming in C++ is done using templates, though macros are still supported but discouraged. +29. C++ has a total of 97 keywords. + +## Getting Started + +To start programming in C++, you'll need a development environment with a C++ compiler. Popular compilers include GCC, Clang, and Microsoft Visual C++. You can choose an Integrated Development Environment (IDE) like Visual Studio, Code::Blocks, or CLion to write and compile your code efficiently. + +Here's a simple "Hello, World!" example in C++: + +```cpp +#include + +int main() { + std::cout << "Hello, World!" << std::endl; + return 0; +} +``` + +Save this code in a file with a `.cpp` extension, compile it using a C++ compiler, and execute the resulting program to see the output. + +## What's Next? + +- **Learn Basic Syntax**: Dive into the syntax, data types, control structures, and functions in C++. +- **Explore Advanced Concepts**: Study topics like pointers, memory management, templates, and exception handling. +- **Practice, Practice, Practice**: Solve programming challenges and work on projects to reinforce your learning. +- **Refer Official Documentation**: Utilize online resources, books, and official C++ references to deepen your understanding. + +C++ is a vast language with numerous possibilities. Enjoy your journey in mastering this versatile programming language! + +--- + +Feel free to expand upon this content and include more details, examples, or exercises based on your audience's needs and the depth of the tutorial you're planning to create. + +