C++ Standards Support in GCC

Vrundesha Joshi
Updated on 11-Feb-2020 12:54:12

1K+ Views

GCC supports different dialects of C++, corresponding to the multiple published ISO standards. Which standard it implements can be selected using the -std= command-line option.C++98 − GCC has full support for the 1998 C++ standard as modified in 2003 and renamed to C++03 and some later defect reports.C++11 − GCC 4.8.1 was the first complete implementation of the 2011 C++ standard, previously known as C++0x.C++14 − GCC has full support for the latest revision of the C++ standard, which was published in 2014.C++17 − GCC has experimental support for the next revision of the C++ standard, which is expected to ... Read More

What are Aggregates and PODs in C++

George John
Updated on 11-Feb-2020 12:49:57

804 Views

POD is an acronym in C++ that means plain old data. It is a class/struct that ONLY has member variables and no methods, constructors, destructors, virtual functions, etc. For example, Example#include using namespace std; // POD struct MyStruct {    int key;    string data; }; int main() {    struct MyStruct s;    s.key = 1;    s.data = "hello";    return 0; }The struct MyStruct has no user defined ctor, dtor, etc and hence is a POD.An aggregate is an array or a class with no user-declared constructors, no private or protected non-static data members, no base ... Read More

Detect Double Click Events of JTable Row in Java

raja
Updated on 11-Feb-2020 12:07:15

4K+ Views

A JTable is a subclass of JComponent for displaying complex data structures. A JTable can follow the Model View Controller (MVC) design pattern for displaying the data in rows and columns. A JTable can generate TableModelListener, TableColumnModelListener, ListSelectionListener, CellEditorListener and RowSorterListener interfaces. We can detect the double click events of a JTable by using a MouseAdapter class or MouseListener interface. We can set the getClickCount() value to '2' of a MouseEvent class for detecting the double click events of a JTable.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public final class DoublClickJTableRowTest extends JFrame {    private JTable table;    private JScrollPane scrollPane;    public DoublClickJTableRowTest() {   ... Read More

C++ vs C++0x vs C++11 vs C++98

Smita Kapse
Updated on 11-Feb-2020 11:15:38

2K+ Views

C++98 was the first edition of the C++ standard. It had defined all the basic language constructs, the STL, and the standard library.C++03 was the next revision to this standard. This was majorly a considered a bugfix for the standard as it corrected 92 core language defect reports, 125 library defect reports, and included only one new language feature: value initialization.C++0x was the name of the work in progress that was expected to complete by 2008-09 but finally completed in 2011.C++11 was the modern C++ standard published in 2011. This brought many major extensions and improvements to the existing language. ... Read More

Importance of JViewport Class in Java

raja
Updated on 11-Feb-2020 11:11:40

517 Views

JViewportA JViewport class defines the basic scrolling model and it is designed to support both logical scrolling and pixel-based scrolling.The viewport's child called the view is scrolled by calling JViewport.setViewPosition() method.A JViewport class supports logical scrolling, that is a kind of scrolling in which view coordinates are not pixels.To support a logical scrolling, JViewport defines a small set of methods that can be used to define the geometry of a viewport and a view. By default, these methods just report the pixel dimensions of the viewport and view.Exampleimport java.awt.*; import javax.swing.*; public class JViewportTest extends JFrame {    public JViewportTest() {       setTitle("JViewport Test"); ... Read More

Declare Two-Dimensional Array in C++ Using New

Chandu yadav
Updated on 11-Feb-2020 11:07:10

2K+ Views

A dynamic 2D array is basically an array of pointers to arrays. So you first need to initialize the array of pointers to pointers and then initialize each 1d array in a loop.example#include using namespace std; int main() {    int rows = 3, cols = 4;    int** arr = new int*[rows];    for(int i = 0; i < rows; ++i)    arr[i] = new int[cols];    return 0; } This will create an 2D array of size 3x4. Be vary of clearing the memory in such cases as you'll need to delete the memory in the ... Read More

Difference between const int, const int*, and int* in C/C++

George John
Updated on 11-Feb-2020 11:04:26

4K+ Views

The above symbols mean the following −int* - Pointer to int. This one is pretty obvious. int const * - Pointer to const int. int * const - Const pointer to int int const * const - Const pointer to const intAlso note that −const int * And int const * are the same. const int * const And int const * const are the same.If you ever face confusion in reading such symbols, remember the Spiral rule: Start from the name of the variable and move clockwise to the next pointer or type. Repeat until expression ends.

Tokenize a String in C++

Ramu Prasad
Updated on 11-Feb-2020 11:03:12

380 Views

First way is using a stringstream to read words seperated by spaces. This is a little limited but does the task fairly well if you provide the proper checks. example#include #include #include using namespace std; int main() {    string str("Hello from the dark side");    string tmp; // A string to store the word on each iteration.    stringstream str_strm(str);    vector words; // Create vector to hold our words    while (str_strm >> tmp) {       // Provide proper checks here for tmp like if empty       // ... Read More

Read and Parse CSV Files in C++

Nitya Raut
Updated on 11-Feb-2020 10:54:53

3K+ Views

You should really be using a library to parsing CSV files in C++ as there are many cases that you can miss if you read files on your own. The boost library for C++ provides a really nice set of tools for reading CSV files. For example, example#include vector parseCSVLine(string line){    using namespace boost;    std::vector vec;    // Tokenizes the input string    tokenizer tk(line, escaped_list_separator    ('\', ', ', '\"'));    for (auto i = tk.begin();  i!=tk.end();  ++i)    vec.push_back(*i);    return vec; } int main() {    std::string line = "hello, from, ... Read More

Set, Clear and Toggle a Bit in C/C++

Chandu yadav
Updated on 11-Feb-2020 10:52:13

9K+ Views

You can set clear and toggle bits using bitwise operators in C, C++, Python, and all other programming languages that support these operations. You also need to use the bitshift operator to get the bit to the right place.Setting a bitTo set a bit, we'll need to use the bitwise OR operator −Example#include using namespace std; int main() {    int i = 0, n;        // Enter bit to be set:    cin >> n;    i |= (1 > n;    i ^= (1

Advertisements