Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Object Oriented Programming Articles
Page 194 of 589
C Program to find IP Address, Subnet Mask & Default Gateway
C programming language can be used to find the details of the Internet connection of the system. Now, let's learn about the basic terms that we need in this problem. IP Address − IP Address stands for Internet Protocol address. An IP address is a fixed numerical identification number that is associated with each device. IP address allows communication of your device using IP address over the internet. Subnet Mask − A 32-bit component of the IP address. The subnet mask differentiates the network component of IP address into two parts. One being network address and other being ...
Read MoreHow do I set up C/C++ on Eclipse in Windows?
Setting up C/C++ development environment on Eclipse in Windows requires installing a compiler and the Eclipse CDT plugin. This guide walks you through the complete setup process using MinGW GCC compiler. Prerequisites System Requirements: Windows 7 or later, Java 8 or higher installed on your system. Step 1: Install MinGW GCC Compiler Eclipse requires a C/C++ compiler to build and run programs. MinGW (Minimalist GNU for Windows) is recommended for its simplicity − Visit the MinGW official website at www.mingw.org Download the latest MinGW installation program (MinGW-.exe) Run the installer and select ...
Read MoreWhen to use C over C++, and C++ over C?
Both C and C++ are powerful programming languages used by developers to write system-level and application programs. C follows a procedural programming paradigm with a simple and structured approach, while C++ supports both procedural and object-oriented programming. Although both languages are widely used across various fields, they have different strengths and use cases. This article explores when to choose C over C++ and vice versa. When to Use C Language? C is preferred in the following scenarios − System Programming: When writing low-level system software like operating systems, embedded systems, or ...
Read MoreWhat is the difference Between C and C++?
C and C++ are closely related programming languages, with C++ being developed as an extension of C. While they share many similarities, there are fundamental differences in their design philosophy and features. Key Differences Between C and C++ Aspect C C++ Programming Paradigm Procedural Programming Object-Oriented Programming Building Blocks Functions Objects and Classes Memory Management malloc() and free() new and delete operators Variable References Not supported Supported Function Overloading Not supported Supported Operator Overloading Not supported Supported Exception Handling Not supported try-catch ...
Read MoreWhat is traits in PHP?
In PHP 5.4, traits were introduced to object-oriented programming to solve the limitations of single inheritance. A trait is similar to a class but is designed specifically for grouping methods in a fine-grained and reusable way. Unlike classes, traits cannot be instantiated directly − they must be used within classes using the use keyword. Syntax trait TraitName { // methods and properties } class ClassName { use TraitName; // class methods and properties } Example Here's how to define and use ...
Read MoreWhat is dependency injection in PHP?
Dependency injection is a design pattern where objects receive their dependencies from external sources rather than creating them internally. This approach promotes loose coupling, improves testability, and makes code more maintainable by avoiding hard-coded dependencies. There are several approaches to inject dependencies into objects. Here are the most commonly used methods − Constructor Injection In this approach, dependencies are injected through the class constructor when the object is instantiated − Total skills: 3 Skills: PHP, JQUERY, AJAX Setter Injection In setter injection, dependencies are provided through setter methods ...
Read MoreWhat is singleton design concept in PHP?
Singleton Pattern ensures that a class has only one instance and provides a global point to access it. It ensures that only one object is available all across the application in a controlled state. Singleton pattern provides a way to access its only object which can be accessed directly without the need to instantiate the object of the class. Example Output connection created bool(true) Key Benefits The Singleton pattern offers several advantages − Memory efficiency: Only one instance exists throughout the application Global access: The instance can ...
Read MoreHow to remove non-alphanumeric characters in PHP stirng?
We can remove non-alphanumeric characters from a string using the preg_replace() function in PHP. The preg_replace() function is an inbuilt function that performs regular expression search and replace operations. Syntax preg_replace(pattern, replacement, subject, limit, count) Parameters pattern: The regular expression pattern to search for. replacement: The string or array to replace matched patterns with. subject: The string or array to search and replace in. limit: Optional. Maximum possible replacements for each pattern. count: Optional. Variable that will contain the number of replacements performed. Example Let's demonstrate how to ...
Read MoreHow to call parent constructor in child class in PHP?
In PHP object-oriented programming, there are two scenarios when calling parent constructors in child classes, depending on whether the child class defines its own constructor. Case 1: Child Class Has Its Own Constructor When a child class defines its own constructor, the parent constructor is not automatically called. You must explicitly call parent::__construct() within the child constructor to execute the parent's initialization code ? I am in Tutorials Point I am not in Tutorials Point Explanation In the above example, parent::__construct() explicitly calls the parent class constructor before executing ...
Read MoreWhat is Pass By Reference and Pass By Value in PHP?
In PHP, you can pass arguments to functions using two methods: pass by value (default) and pass by reference. Understanding the difference is crucial for effective programming. By default, PHP uses pass by value, meaning the function receives a copy of the variable. Changes inside the function don't affect the original variable. However, pass by reference allows the function to modify the original variable by using the ampersand (&) symbol. Pass By Reference To pass a variable by reference, prepend an ampersand (&) to the parameter name in the function definition. This allows the function to modify ...
Read More