DEV Community

Adhyan Jain
Adhyan Jain

Posted on • Edited on

Week 2 of My C++ Learning Journey: Advancing with Strings, Bit Manipulation & OOP

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)