Anvi Jain has Published 629 Articles

Pure virtual destructor in C++

Anvi Jain

Anvi Jain

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

476 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

Replace part of string in MySQL table column?

Anvi Jain

Anvi Jain

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

379 Views

To replace part of string in MySQL table column, you can use REPLACE(). Following is the syntax −update yourTableName set yourColumnName = REPLACE(yourColumnName ,'yourOldValue', 'yourNewValue');Let us first create a table −mysql> create table replacePartOfStringDemo    -> (    -> WebsiteURL varchar(100)    -> ); Query OK, 0 rows affected (0.47 ... Read More

How to get latitude from Network provider in android?

Anvi Jain

Anvi Jain

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

209 Views

This example demonstrate about How to get latitude from Network provider in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the ... Read More

How to get element with max id in MongoDB?

Anvi Jain

Anvi Jain

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

975 Views

To get the element with a max id, you can use the find() method. To understand the above concept, let us create a collection with the document. The query is as follows −> db.getElementWithMaxIdDemo.insertOne({"Name":"John", "Age":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8bbce480f10143d8431e1c") } > db.getElementWithMaxIdDemo.insertOne({"Name":"Larry", "Age":24}); {   ... Read More

The most elegant way to iterate the words of a string using C++

Anvi Jain

Anvi Jain

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

100 Views

There is no one elegant way to iterate the words of a C/C++ string. The most readable way could be termed as the most elegant for some while the most performant for others. I've listed 2 methods that you can use to achieve this. First way is using a stringstream ... Read More

Remove Trailing Zero in MySQL?

Anvi Jain

Anvi Jain

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

1K+ Views

Use trim() function to remove trailing zeroz in MySQL. Following is the syntax −select trim(yourColumnName)+0 As anyAliasName from yourTableName;Let us first create a table −mysql> create table removeTrailingZero    -> (    -> Number DECIMAL(10, 4)    -> ); Query OK, 0 rows affected (0.83 sec)Following is the query to ... Read More

Can a C++ virtual functions have default parameters?

Anvi Jain

Anvi Jain

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

704 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

MySQL query to find sum of fields with same column value?

Anvi Jain

Anvi Jain

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

603 Views

Use GROUP BY clause for this. Let us first create a table −mysql> create table sumOfFieldsDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> ClientSerialNumber varchar(100),    -> ClientCost int    -> ); Query OK, 0 rows affected (0.50 sec)Following is the query to ... Read More

How to use length () in Android sqlite?

Anvi Jain

Anvi Jain

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

330 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to ... Read More

Case insensitive search in Mongo?

Anvi Jain

Anvi Jain

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

2K+ Views

You can restrict case insensitive search in MongoDB with the help of '$regex'. The syntax is as follows −db.yourCollectionName.find({"yourFieldName" : { '$regex':'^yourValue$'}});You can use another regex. The syntax is as follows −db.yourCollectionName.find({"Name" : { '$regex':/^yourValue$/i}});To understand the concept, let us create a collection with the document. The query to create ... Read More

Advertisements