Found 7346 Articles for C++

C++ Program to Implement Dequeue

Anvi Jain
Updated on 30-Jul-2019 22:30:25

9K+ Views

Dequeue or Double Ended Queue is a generalized version of Queue data structure that allows insert and delete at both ends.Some basic operations of dequeue are −insert_at_beg(): inserts an item at the front of Dequeue.insert_at_end(): inserts an item at the rear of Dequeue.delete_fr_beg(): Deletes an item from front of Dequeue.delete_fr_rear(): Deletes an item from rear of Dequeue.Following is a C++ program to implement DequeueAlgorithmBegin    Declare a class dequeue to declare front f and rear r and following functions:    function insert_at_beg(int) to insert item at front:       If queue is not completely filled up, insert element at ... Read More

C++ Program to Implement Stack Using Two Queues

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

985 Views

StackThe stack which is implemented as LIFO, where insertion and deletion are done from the same end, top. The last element that entered is deleted first.Stack operations are −push (int data) − Insertion at topint pop() − Deletion from topQueueThe queue which is implemented as FIFO where insertions are done at one end (rear) and deletions are done from another end (front). The first element that entered is deleted first.Queue operations are −EnQueue (int data) − Insertion at the rear endint DeQueue() − Deletion from front endThis is a C++ Program to Implement Stack Using Two QueuesAlgorithmsBegin    function enqueue1 to ... Read More

cout << endl vs cout << “” in C++

Nitya Raut
Updated on 30-Jul-2019 22:30:25

905 Views

In this section we will see what are the differences between cout

C++ Program to Implement Queue Using Two Stacks

Anvi Jain
Updated on 30-Jul-2019 22:30:25

2K+ Views

StackThe stack which is implemented as LIFO, where insertion and deletion are done from the same end, top. The last element that entered is deleted first.Stack operations are −push (int data) − Insertion at topint pop() − Deletion from topQueueThe queue which is implemented as FIFO where insertions are done at one end (rear) and deletions are done from another end (front). The first element that entered is deleted first.Queue operations are −EnQueue (int data) − Insertion at rear endint DeQueue() − Deletion from front endThis is a C++ Program to Implement Queue Using Two Stacks.Description of functionsfunction enQueue() to ... Read More

C++ Program to Implement the String Search Algorithm for Short Text Sizes

Smita Kapse
Updated on 30-Jul-2019 22:30:25

345 Views

In this C++ program, as input, a text and a pattern are given. As output, the pattern is searched in the text and all instances of the pattern are given.AlgorithmBegin    Take the string and pattern as input.    Declare the original and duplicate array with their size.    Put the lengths of original and duplicate in len_ori and len_dupli.    Make a loop for find out the position of the searched pattern.    If pattern is not found, print not found otherwise print the no of instances of the searched pattern. EndExample Code Live Demo#include #include using namespace std; ... Read More

C++ Program to Implement Bitap Algorithm for String Matching

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

329 Views

This is a C++ Program to Implement Bitap Algorithm for String Matching. The algorithm tells whether a given text contains a substring which is “approximately equal” to a given pattern, where approximate equality is defined in terms of Levenshtein distance — if the substring and pattern are within a given distance k of each other, then according to the algorithm they are equal. It begins by precomputing a set of bitmasks containing one bit for each element of the pattern. So we are able to do most of the work with bitwise operations, which are extremely fast.AlgorithmBegin    Take the ... Read More

Can a C++ virtual functions have default parameters?

Anvi Jain
Updated on 30-Jul-2019 22:30:25

705 Views

Yes, C++ virtual functions can have default parameters.Example Code Live Demo#include using namespace std; class B {    public:       virtual void s(int a = 0) {          cout

SQL using C/C++ and SQLite

Nitya Raut
Updated on 30-Jul-2019 22:30:25

2K+ Views

In this section, you will learn how to use SQLite in C/C++ programs.InstallationBefore you start using SQLite in our C/C++ programs, you need to make sure that you have SQLite library set up on the machine. You can check SQLite Installation chapter to understand the installation process.C/C++ Interface APIsFollowing are important C/C++ SQLite interface routines, which can suffice your requirement to work with SQLite database from your C/C++ program. If you are looking for a more sophisticated application, then you can look into SQLite official documentation.Serial NoAPI & Description1sqlite3_open(const char *filename, sqlite3 **ppDb)This routine opens a connection to an SQLite ... Read More

Calling virtual functions inside constructors in C++

Smita Kapse
Updated on 30-Jul-2019 22:30:25

197 Views

Virtual functions calling from a constructor or destructor is dangerous and should be avoided whenever possible as the virtual function we call is called from the Base class and not from the derived class.The reason is that in C++ Super-classes are constructed before derived classes. So, in the following example, as B must be instantiated, before D is instantiated. When B's constructor is called, it's not D yet, so the virtual function table still has the entry for B's copy of s().Example Code Live Demo#include using namespace std; class B {    public: B() {       s();    } ... Read More

Database Connectivity using C/C++

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

3K+ Views

In this section, you will learn how to use SQLite in C/C++ programs.InstallationBefore you start using SQLite in our C/C++ programs, you need to make sure that you have SQLite library set up on the machine. You can check the SQLite Installation chapter to understand the installation process.C/C++ Interface APIsFollowing are important C/C++ SQLite interface routines, which can suffice your requirement to work with SQLite database from your C/C++ program. If you are looking for a more sophisticated application, then you can look into SQLite official documentation.Serial NoAPI & Description1sqlite3_open(const char *filename, sqlite3 **ppDb)This routine opens a connection to an ... Read More

Advertisements