Another week of coding, another set of challenges! In Week 2, I dived deeper into C++ by exploring advanced topics like strings, bitwise operations, and object-oriented programming (OOP). Each day brought new concepts and problem-solving techniques that strengthened my understanding of C++.
Day 8: Exploring Strings
Strings are an essential part of C++ programming, used for handling text and character data.
π Topics Covered:
β
Character arrays vs. string class
β
String operations (concatenation, comparison, substring)
β
String manipulation functions
β
String streams
π» Key Practice:
πΉ Reversed a string
πΉ Checked if a string is a palindrome
πΉ Counted vowels and consonants
πΉ Removed spaces from a string
πΉ Found the first non-repeating character
Day 9: Introduction to Bitwise Operations
Bitwise operations allow efficient manipulation of individual bits, which is useful for optimizing performance.
π Topics Covered:
β
AND, OR, XOR, NOT operators
β
Left & Right Shift operations
β
Setting, clearing, and toggling bits
β
Updating the i-th bit
π» Key Practice:
πΉ Extracted the i-th bit of a number
πΉ Set and cleared specific bits
πΉ Toggled bits in an integer
πΉ Implemented bitwise tricks for fast computations
Day 10: Advanced Bit Manipulation
Taking bitwise operations further, I explored real-world applications of bit manipulation.
π Topics Covered:
β
Checking if a number is a power of 2
β
Counting set bits efficiently
β
Generating subsets using bitwise techniques
π» Key Practice:
πΉ Counted the number of ones in a binary representation
πΉ Generated all subsets of an integer set
πΉ Generated all subsets of a character set
Day 11: XOR Properties & Unique Number Problems
XOR operations have powerful applications in finding unique numbers in an array.
π Topics Covered:
β
XOR properties and their applications
β
Finding unique numbers in different scenarios
β
Efficiently counting set bits
π» Key Practice:
πΉ Found a unique number in an array where all others appear twice
πΉ Found two unique numbers in an array
πΉ Found a unique number where all others appear thrice
Day 12: Structures, Unions, and Enums
Structures and unions help in organizing and optimizing data storage, while enums provide meaningful constants.
π Topics Covered:
β
Defining and using structures
β
Memory efficiency with unions
β
Using enums for readability
π» Key Practice:
πΉ Created an Employee struct and found the highest salary
πΉ Demonstrated how unions store different data types
πΉ Implemented an enum for days of the week
Day 13: Introduction to Classes & Objects
Classes are the foundation of object-oriented programming in C++.
π Topics Covered:
β
Defining and using classes
β
Object-oriented programming basics
β
Access specifiers: public, private, protected
π» Key Practice:
πΉ Created a Student class with attributes
πΉ Implemented a Circle class with a function to calculate area
Day 14: Nesting of Member Functions
I explored function nesting inside classes to enhance encapsulation.
π Topics Covered:
β
Private member functions
β
Nesting functions for better encapsulation
β
Oneβs complement operation
π» Key Practice:
πΉ Validated binary format using a private function
πΉ Performed oneβs complement operation
πΉ Implemented binary addition using a Binary class
Key Takeaways from Week 2:
πΉ Bit manipulation is an incredibly powerful technique for optimizing performance in problem-solving. If you understand the logic you'll find it much better than normal way of solving a problem. Though it was a bit tough understanding the concepts I am sure it would be useful later on.
πΉ OOP concepts like classes and structures help in writing organized and maintainable code.
πΉ Strings and their operations are fundamental to text processing in C++.
Whatβs Next?
Next Iβll explore dynamic memory allocation, inheritance, and polymorphism to deepen my OOP understanding.
Learning C++ has been an exciting journey so far, and Iβm eager to keep pushing forward! Let me know your thoughtsβhow do you approach these concepts in C++? π
Top comments (0)