Argument-dependent lookup(ADL) is a protocol for looking up unqualified function names in function-call expressions.These function call expressions include implicit function calls to overloaded operators.The function names are looked up in the namespaces of their arguments in addition to the scopes and namespaces considered by the usual unqualified name lookup. Argument-dependent lookup makes it possible to use operators defined in a different namespace. Examplenamespace MyNamespace{ class A {}; void f( A &a, int i) {} } int main() { MyNamespace::A a; f( a, 0 ); //calls MyNamespace::f }The lookup of a function call to f was dependent ... Read More
A JComboBox is a subclass of JComponent class and it is a combination of a text field and a drop-down list from which the user can choose a value. A JComboBox can generate an ActionListener, ChangeListener, and ItemListener interfaces when the user actions on a combo box.We can implement auto-complete JComboBox when the user types an input value from a keyboard by using customization of a combo box (AutoCompleteComboBox) by extending the JComboBox class.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.plaf.basic.*; public class AutoCompleteComboBoxTest extends JFrame { private JComboBox comboBox; public AutoCompleteComboBoxTest() { setTitle("AutoCompleteComboBox"); ... Read More
You can use the c_str() method of the string class to get a const char* with the string contents. example#include using namespace std; int main() { string x("hello"); const char* ccx = x.c_str(); cout
You can use a string stream to parse an int in c++ to an int. You need to do some error checking in this method.example#include #include using namespace std; int str_to_int(const string &str) { stringstream ss(str); int num; ss >> num; return num; } int main() { string s = "12345"; int x = str_to_int(s); cout
A portable solution doesn't exist for doing this. On windows, you can use the getch() function from the conio(Console I/O) library to get characters pressed.example#include #include using namespace std; int main() { char c; while(1){ // infinite loop c = getch(); cout
You can sort a vector of custom objects using the C++ STL function std::sort. The sort function has an overloaded form that takes as arguments first, last, comparator. The first and last are iterators to first and last elements of the container. The comparator is a predicate function that can be used to tell how to sort the container. example#include #include #include using namespace std; struct MyStruct { int key; string data; MyStruct(int key, string data) { this -> key = key; this -> data = data; } }; int ... Read More
A JTable is a subclass of JComponent class and it can be used to create a table with information displayed in multiple rows and columns. When a value is selected from a JTable, a TableModelEvent is generated, which is handled by implementing a TableModelListener interface.In general, a user can select the rows and columns manually in a JTable, we can also select different cells of a JTable programmatically using setRowSelectionInterval() and setColumnSelectionInterval() methods of JTable class.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; public class JTableCellSelectionTest extends JFrame { private JTable table; public JTableCellSelectionTest() { setTitle("JTableCellSelection Test"); Object[][] data = ... Read More
Forward declaration lets the code following the declaration know that there is are classes with the name Person. This satisfies the compiler when it sees these names used. Later the linker will find the definition of the classes. exampleClass Person; void myFunc(Person p1) { // ... } Class Person { // Class definition here };So in this case when the compiler encounters myFunc, it'll know that it's going to encounter this class somewhere down in the code. This can be used in cases where code using the class is placed/included before the code containing the class definition.
A JSlider is a subclass of JComponent class and it is similar to scroll bar which allows the user to select a numeric value from a specified range of integer values. A JSlider has a knob which can slide on a range of values and can be used to select a particular value. and it can generate a ChangeListener interface.We can detect the value changed when the slider is moved horizontally using the Graphics2D class and override paint() method.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class ValueChangeJSliderTest extends JFrame { private JSlider slider; public ValueChangeJSliderTest() { ... Read More
It can be done with the SHOW COLUMNS statement. Its Syntax would be as follows:SyntaxSHOW COLUMNS FROM tab_name IN db_nameHere, tab_name is the name of the table from which we want to see the list of columns.Db_name is the name of the database, in which the table is storedExampleIn the example, we are currently using the database ‘query’ and getting the list of columnsfrom a table named ‘arena’ stored in MySQL ‘database’:mysql> SHOW COLUMNS FROM arena IN mysql\G *************************** 1. row *************************** Field: id Type: int(10) unsigned zerofill Null: NO Key: PRI Default: NULL Extra ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP