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++? ๐