Smita Kapse has Published 558 Articles

Can main() be overloaded in C++?

Smita Kapse

Smita Kapse

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

552 Views

In C++, we can use the function overloading. Now the question comes in our mind, that, can we overload the main() function also?Let us see one program to get the idea.Example#include using namespace std; int main(int x) {    cout

Search a sub-field on MongoDB?

Smita Kapse

Smita Kapse

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

235 Views

To search a sub-filed in MongoDB, you can use double quotes along with dot notation. Let us first create a collection with documents −> db.searchSubFieldDemo.insertOne( ...   { ...      "UserDetails": ...      {"UserEmailId":"John123@gmail.com", "UserAge":21} ...   } ... ); {    "acknowledged" : true,    "insertedId" : ... Read More

Inheritance and friendship in C++

Smita Kapse

Smita Kapse

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

2K+ Views

In C++, the friendship is not inherited. It means that, if one parent class has some friend functions, then the child class will not get them as friend.In this example it will generate an error because the display() function is friend of MyBaseClass but not the friend of MyDerivedClass. The ... Read More

Insert MongoDB document field only when it's missing?

Smita Kapse

Smita Kapse

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

238 Views

Let us first create a collection with documents −>db.missingDocumentDemo.insertOne({"StudentFirstName":"Adam", "StudentLastName":"Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3fb1eedc6604c74817ce6") } >db.missingDocumentDemo.insertOne({"StudentFirstName":"Carol", "StudentLastName":"Taylor"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3fb29edc6604c74817ce7") } >db.missingDocumentDemo.insertOne({"StudentFirstName":"David", "StudentLastName":"Miller", "StudentAge":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3fb40edc6604c74817ce8") }Following is the query to display ... Read More

Disable only the vertical scrollbar in Java

Smita Kapse

Smita Kapse

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

1K+ Views

To disable only the vertical scrollbar, use the VERTICAL_SCROLLBAR_NEVER constant, which displays only the horizontal scrollbar.The following is an example to disable only the vertical scrollbar in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JScrollPane; public class SwingDemo {    public static void ... Read More

How can I marquee the text content in Android Notification?

Smita Kapse

Smita Kapse

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

220 Views

This example demonstrate about How can I marquee the text content in Android Notification.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.     ... Read More

Sum MongoDB Sub-documents field?

Smita Kapse

Smita Kapse

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

136 Views

You can use aggregate framework for this. Let us first create a collection with documents −> db.summingSubDocumentDemo.insertOne( ... { "_id" :101, "CustomerDetails" : { "CustomerPurchase" : { "CustomerPurchaseAmount" : 2000 } } }); { "acknowledged" : true, "insertedId" : 101 } > db.summingSubDocumentDemo.insertOne( { "_id" :102, "CustomerDetails" : { ... Read More

How to create an Android notification with a longer text?

Smita Kapse

Smita Kapse

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

284 Views

This example demonstrate about How to create an Android notification with a longer textStep 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.     ... Read More

Calculate average of ratings in array and then include the field to original document in MongoDB?

Smita Kapse

Smita Kapse

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

281 Views

You can use $avg operator along with aggregate framework. Let us first create a collection with documents −> db.averageOfRatingsInArrayDemo.insertOne( ...   { ...      "StudentDetails":[ ...         { ...             "StudentId":1, ...             "StudentScore":45 ... ... Read More

How to determine database type (name) for a given JDBC connection?

Smita Kapse

Smita Kapse

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

3K+ Views

One way to get the name of the underlying database you have connected with is by invoking the getDatabaseProductName() method of the DatabaseMetaData interface. This method returns the name of the underlying database in String format.Therefore, to retrieve the name of your current database using Java code −Retrieve the DatabaseMetaData ... Read More

Advertisements