Nishtha Thakur has Published 495 Articles

What is the effect of extern “C” in C++?

Nishtha Thakur

Nishtha Thakur

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

3K+ Views

The extern “C” keyword is used to make a function name in C++ have the C linkage. In this case the compiler does not mangle the function. Let us see what is the mangling in C++ first, then we can discuss about the extern “C” keyword.In C++ we can use ... Read More

MongoDB equivalent of `select distinct(name) from collectionName where age = “25”`?

Nishtha Thakur

Nishtha Thakur

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

171 Views

You can use distinct() to get the equivalent of select distinct. Let us first create a collection with documents −> db.distinctNameAndAgeDemo.insertOne({"ClientFirstName":"John", "Age":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd12759e3526dbddbbfb60b") } > db.distinctNameAndAgeDemo.insertOne({"ClientFirstName":"Larry", "Age":25}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd12768e3526dbddbbfb60c") } > db.distinctNameAndAgeDemo.insertOne({"ClientFirstName":"David", "Age":25}); {   ... Read More

Java program to get the previous sibling from a JTree

Nishtha Thakur

Nishtha Thakur

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

200 Views

Use the getPreviousSibling() method to get the previous sibling. Here, we are getting the previous sibling of child node “five” and displaying on Console −System.out.println("Get Previous Sibling = "+five.getPreviousSibling());The following is an example to get the previous sibling from a JTree −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public ... Read More

How do I convert between big-endian and little-endian values in C++?

Nishtha Thakur

Nishtha Thakur

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

7K+ Views

Here we will see how to convert Little endian value to Big endian or big endian value to little endian in C++. Before going to the actual discussion, we will see what is the big endian and the little endian?In different architectures, the multi-byte data can be stored in two ... Read More

Why do we check for a NULL pointer before deleting in C/C++?

Nishtha Thakur

Nishtha Thakur

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

549 Views

It is basically pointless to check for a NULL pointer before deleting. Deleting a pointer will do nothing if the pointer set to NULL. It might be the reason to check for the NULL pointer that deleting a pointer which is already set to NULL may indicate bugs in the ... Read More

MongoDB query to get record beginning with specific element from an array?

Nishtha Thakur

Nishtha Thakur

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

243 Views

You can use dot(.) notation along with array index to get record beginning with specific element. Let us first create a collection with documents −>db.arrayStartsWithElementDemo.insertOne({"PlayerName":"Chris", "PlayerScore":[780, 9000, 456, 789, 987]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd29fed345990cee87fd889") } >db.arrayStartsWithElementDemo.insertOne({"PlayerName":"Robert", "PlayerScore":[890, 670, 890, 54646, 42424]}); {    "acknowledged" : ... Read More

How can I drop a collection in MongoDB with two dashes in the name?

Nishtha Thakur

Nishtha Thakur

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

465 Views

Let us first see the syntax to drop a collection −db.getCollection("yourCollectionNameWithTwoDashes").drop();For demo, we will create a collection name with two dashes as shown below −> db.createCollection("company--EmployeeInformation"); { "ok" : 1 }Create the above collection “company--EmployeeInformation “ with documents. Following is the query:>db.getCollection("company--EmployeeInformation").insertOne({"CompanyName":"Amazon", "EmployeeName":"Chris"}); {    "acknowledged" : true,    "insertedId" ... Read More

Java Program to set a spinner of dates in Java

Nishtha Thakur

Nishtha Thakur

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

255 Views

To set a spinner of dates, at first create a date object −Date today = new Date();Now, use SpinnerDateModel −JSpinner spinner2 = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));We will now consider a DateEditor, which is an editor for a JSpinner whose model is a SpinnerDateModel. Set the format for month ... Read More

How to include libraries in Visual Studio 2012?

Nishtha Thakur

Nishtha Thakur

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

1K+ Views

To add libraries in Visual Studio 2012, there are two different methods. The first one is manual method. The second one is adding libraries from code.Let us see the manual method first.To add some library, we have to follow these five steps −Add the #include statements necessary files with proper ... Read More

Selecting database inside the JS in MongoDB?

Nishtha Thakur

Nishtha Thakur

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

147 Views

You can use getSiblingDB() from MongoDB for this using var keyword from JS −anyVariableName= db.getSiblingDB(‘yourDatabaseName’);Let us implement the above syntax in order to select database −> selectedDatabase = db.getSiblingDB('sample');This will produce the following output −SampleNow, insert some documents. Let’s say the collection is ‘selectDatabaseDemo’ −> db.selectDatabaseDemo.insertOne({"ClientName":"John Smith", "ClientAge":23}); {   ... Read More

Advertisements