- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7401 Articles for C++
310 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
309 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
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
176 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
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
5K+ Views
Following table shows the difference between Virtual and Pure Virtual Function:Virtual FunctionPure Virtual FunctionVirtual function has their definition in the class.Pure virtual function has no definition.Declaration: virtual funct_name(parameter_list) {. . . . .};Declaration: virtual funct_name(parameter_list)=0;It has no concept of derived class.If a class contains at least one pure virtual function, then it is declared abstract.If required, the base class can override a virtual function.In case of pure virtual function derived class has to definitely override the pure virtual function.virtual functionExample Code Live Demo#include using namespace std; class B { public: virtual void s() //virtual function { ... Read More
438 Views
The pure virtual destructor is possible in C++. If a class contains pure virtual destructor it is must to provide a function body for the pure virtual destructor.Example Code Live Demo#include using namespace std; class B { public: virtual ~B()=0; // Pure virtual destructor }; B::~B() { std::cout
1K+ Views
Virtual functions in C++ use to create a list of base class pointers and call methods of any of the derived classes without even knowing kind of derived class object. Virtual functions are resolved late, at the runtime.The main use of the virtual function is to achieve Runtime Polymorphism. The inline functions are used to increase the efficiency of the code. The code of inline function gets substituted at the point of an inline function call at compile time, whenever the inline function is called.Whenever a virtual function is called using base class reference or pointer it cannot be inlined, ... Read More
278 Views
Here we will see what is assertions in C/C++. The C library macro void assert(int expression) allows diagnostic information to be written to the standard error file. In other words, it can be used to add diagnostics in your C program.Following is the declaration for assert() Macro.void assert(int expression);The parameter of this assert() is expression − This can be a variable or any C expression. If expression evaluates to TRUE, assert() does nothing. If expression evaluates to FALSE, assert() displays an error message on stderr (standard error stream to display error messages and diagnostics) and aborts program execution.Example Code#include ... Read More
To Continue Learning Please Login
Login with Google