Posts

Friend Function in C++

Image
Friend Function in C++ Welcome to C++ Programming. In this article, we will talk about friend Function and friend Class trying to understand what do they mean and why are they useful in C++ design process. These will be the module outline we will take examples of Matrix Vector Multiplication and Linked List, and finally will end with somenotes. As you know as usual the outline will be available on the left of your slide So, let us first introduce the basic notion of friend function. On the left you have the view of ordinary function. So the situation is like this, that I have a class myclass which as some private data, it has a constructor, and it has; I am sorry if just ignore this line. I have this function written outside of this class which is trying to do something with the class. What is it doing? It takes an object of the class by reference parameter call by reference, and then it tries to print the data element component of that objective. Now, what do we know, this is priva

Use Of CPP

Use Of CPP  In this article we will see some of the termsused with a programming language and then we are going to see the advantages of learning the c++ and then we will see where exactly this C++ programming language is used in the real world. First let's take a look at some of the terms used with the programming language. So the first term is the general purpose programming language. “A general purpose programming language is a language designed to be used for writing the softwares in our wide variety of application domains” In simple words when we say a programming language as a general purpose programming language it means that we can use that programming language to create different variety of applications. This c plus plus is also a general purpose programming language. It means you can use it for creating differentt ypes of softwares or the programs. Now the next thing is C++ is a middle level language. Programming languages is divided into three categories. lower level lan

Data Member and Static Keyword in C++

Image
Data Member and Static Keyword in C++ Hey, what's up guys. My name is Tariq and welcome back to my C++ series Today just coming at you with a quick article and we're going to talk about what static means in C++ so the static Keyword in C++ actually has two meanings depending on what the Context is one of those applies to when you use the static Keyword Outside of a class or a struct and the other is when you use static Inside a class or struct. Basically just to cut to the chase, static outside of class means that the linkage of that symbol that you declare to be static is going to be internal meaning. It's only going to be visible to that translation unit that you've defined it in.  Whereas a static variable inside a class or struct means that variable is actually going to share memory with all of the instances of the class meaning that basically across all instances that you create of that class or struct, there's only going to be one instance of that Static varia

Member Functions in C++

Image
Member Functions in C++ One of the most important concept is OOP in C++ and other programming langauages. When it comes to member function it is important to know three things about class. The first thing is data member the second thing is member function and the third thing is access specifiers. There are two types of member functions or member methods. The first type is non-static function which is also known as non-static method and the second type is static function whic is also known as static method. Example void display(){} // This is non-static function static void display(){} // This is static function Reference To Learn More https://www.info999.gq/2020/07/Constructor-C.html https://www.info999.gq/2020/07/how-to-use-class-and-object-in-c.html https://www.studytonight.com/cpp/member-functions-cpp.php

Constructor C++

Image
Constructor C++                         Constructor is used to initailize the data members automatically.A constructor is a member function of class.It execute when object of that class created.It means that when object of class created the constructor executes automatically.By default there is constructor even if you dont write it.  Constructor Syntax                           The syntax of constructor is like same name of class e.g if the name of class is A so the constuctor will start with A(){ here is the body }. Copy Constructor C++                    Just read about copy constructor and assignment operator they can create a big problem in real world projects they cannot be used but for you should have some knowledge about it.

How To Use Class and Object In C++

Image
Class and Object In C++                             In C++ the concept of classes and objects is very useful.Now lets see how to use it and what is the syntax.Simply the class is written same as its name like class before the main method.Class with brackets like class{}.                                   Now lets take a look to object it is a logical thing.If you have class A and we want to create its object.We will do in main method A object; The A refers to class A and object refers to the object of class A.                                    Now lets create a function in class A.We have class A{} inside the brackets we will write public: just ignore what is this just write it for now after that in next line write void show(){ cout<<"Member function"<<endl;} Now we have create a function in a class.                                     Now we will call this function in main function with the object of class.After the A object in main just in next line write objec

Virtual Destructors In C++

Virtual Destructors In C++                             Base class destructor should always be virtual.The reason is if you want to delete the object of derived class it will not deleted.Lets take an example: Forexample           class A{                          public:                           ~A(){                                    cout<<"Base Class"<<endl;                                     }                            };           class B :public A{                          public:                           ~B(){                                    cout<<"Derived Class"<<endl;                                     }                             };          int main(){                               A *ptr=new B;                               delete ptr;                               return 0;                               } Output                     Base Class                              From above the example you can see that the base c