Smita Kapse has Published 498 Articles

Why “using namespace std” is considered bad practice in C++

Smita Kapse

Smita Kapse

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

2K+ Views

C++ has a standard library that contains common functionality you use in building your applications like containers, algorithms, etc. If names used by these were out in the open, for example, if they defined a queue class globally, you'd never be able to use the same name again without conflicts. ... Read More

Check if a list is not empty in MongoDB?

Smita Kapse

Smita Kapse

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

433 Views

For this, use the $size operator. Let us first create a collection with documents −> db.checkIfListIsNotEmptyDemo.insertOne({"UserFriendGroup":["John", "David"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdd99e8bf3115999ed511f7") } > db.checkIfListIsNotEmptyDemo.insertOne({"UserFriendGroup":["Carol"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdd99e9bf3115999ed511f8") } > db.checkIfListIsNotEmptyDemo.insertOne({"UserFriendGroup":[]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdd99ebbf3115999ed511f9") ... Read More

What is the difference between a destructor and a free function in C++?

Smita Kapse

Smita Kapse

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

606 Views

Here we will see what are the differences between destructor and the free() functions in C++. The destructor is used to perform some action, just before the object is destroyed. This action may not freeing up the memory, but can do some simple action such as displaying one message on ... Read More

Count the number of objects using Static member function in C++

Smita Kapse

Smita Kapse

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

7K+ Views

Here we will see how to count number of objects are created from a specific class using some static member functions. The static members are class properties, not the object properties. For a single class there will be only one instance for static members. No new members are created for ... Read More

How to get the number of rows and columns of a JTable in Java Swing

Smita Kapse

Smita Kapse

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

2K+ Views

To count the number of rows of a table, use the getRowCount() method −table.getRowCount()To count the number of columns of a table, use the getColumnCount() method −table.getColumnCount()The following is an example to get the number of rows and columns of a JTable −Examplepackage my; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JScrollPane; ... Read More

MongoDB query to find a value from JSON like data?

Smita Kapse

Smita Kapse

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

5K+ Views

To fund a value from JSON data, use the find() along with dot(.) notation. Let us first create a collection with documents −> db.findValueFromJsonDemo.insertOne(    {       "UserDetails": [{          "_id": new ObjectId(),          "UserName": "Carol",          "UserMessage": "Hi" ... Read More

How to pull an array element (which is a document) in MongoDB?

Smita Kapse

Smita Kapse

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

220 Views

You can use $pull operator. Let us first create a collection with documents −> db.pullAnArrayElementDemo.insertOne( { "StudentDetails": [ { "StudentFirstName":"Chris", "StudentScore":56 }, {"StudentFirstName":"Robert", "StudentScore":59 } ] } ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3b55bedc6604c74817cd5") }Following is the query to display all documents from a collection with the ... Read More

static keyword in C++ vs Java

Smita Kapse

Smita Kapse

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

651 Views

In C++ or Java we can get the static keyword. They are mostly same, but there are some basic differences between these two languages. Let us see the differences between static in C++ and static in Java.The static data members are basically same in Java and C++. The static data ... Read More

Get the size of all the documents in a MongoDB query?

Smita Kapse

Smita Kapse

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

310 Views

To get the size of all the documents in a query, you need to loop through documents. Let us first create a collection with documents −> db.sizeOfAllDocumentsDemo.insertOne({"StudentFirstName":"John", "StudentSubject":["MongoDB", "Java"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd3c0c1edc6604c74817cd7") } > db.sizeOfAllDocumentsDemo.insertOne({"StudentFirstName":"Larry", "StudentSubject":["MySQL", "PHP"], "StudentAge":21}); {    "acknowledged" : true,   ... Read More

Anything written in sizeof() is never executed in C

Smita Kapse

Smita Kapse

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

168 Views

The sizeof function (Sometimes called operator) is used to calculate the size of the given argument. If some other functions are given as argument, then that will not be executed in the sizeof.In the following example we will put one printf() statement inside the loop. Then we will see the ... Read More

Advertisements