Find Current C or C++ Standard Documents

Nishtha Thakur
Updated on 23-Jun-2020 13:59:38

141 Views

You can find the current C standard documents on ANSI web store. https://webstore.ansi.org/RecordDetail.aspx?sku=INCITS%2FISO%2FIEC+9899-2012You can find the current C++ standard documents on the ISO C++ website for buying −  https://www.iso.org/standard/68564.htmlThe working draft of the ISO C++ standard is also available on  https://isocpp.org/std/the-standard

When to Use Static Cast, Dynamic Cast, Const Cast, and Reinterpret Cast in C++

V Jyothi
Updated on 23-Jun-2020 13:57:11

4K+ Views

const_castcan be used to remove or add const to a variable. This can be useful if it is necessary to add/remove constness from a variable.static_castThis is used for the normal/ordinary type conversion. This is also the cast responsible for implicit type coersion and can also be called explicitly. You should use it in cases like converting float to int, char to int, etc.dynamic_castThis cast is used for handling polymorphism. You only need to use it when you're casting to a derived class. This is exclusively to be used in inheritence when you cast from base class to derived class.reinterpret_castThis is ... Read More

Copy and Swap Idiom in C++

Ankith Reddy
Updated on 23-Jun-2020 13:51:21

325 Views

The assignment consists of 2 steps, tearing an object's old state and building a new state for it. The destructor is used for the first step and a copy constructor does the second step. Implementing both of these is straightforward. But when overloading the assignment operator, it can become quite difficult to implement. The copy and swap idiom is a solution for the same.This idiom uses the copy-constructor to build a local copy of the data. It then swaps the old data with the new data using the swap function. The temporary copy is then destructed using the destructor. We ... Read More

Differences Between Pointer Variable and Reference Variable in C++

George John
Updated on 23-Jun-2020 13:49:38

1K+ Views

ReferencesWhen a variable is declared as a reference, it becomes an alternative name for an existing variable.Syntax Type &newname = existing name;InitializationType &pointer; pointer = variable name;PointersPointers are used to store the address of a variable.SyntaxType *pointer;InitializationType *pointer; pointer = variable name;The main differences between references and pointers are -References are used to refer an existing variable in another name whereas pointers are used to store the address of a variable.References cannot have a null value assigned but pointer can.A reference variable can be referenced bypass by value whereas a pointer can be referenced but pass by referenceA reference must ... Read More

Faster Array Processing: Sorted vs Unsorted in C++

Anvi Jain
Updated on 23-Jun-2020 13:43:58

318 Views

In C++, it is faster to process a sorted array than an unsorted array because of branch prediction. In computer architecture, a branch prediction determines whether a conditional branch (jump) in the instruction flow of a program is likely to be taken or not.Let’s take an example −if(arr[i] > 50) {    Do some operation B } else {    Do some operation A }If we run this code for 100 elements in unsorted and sorted order below things will be happened −For sorted array −1, 2, 3, 4, 5, …… 50, 51………100 A, A, A, A, A A, B ... Read More

Rule of Three in C++

Govinda Sai
Updated on 23-Jun-2020 13:40:50

177 Views

The Rule of three is a rule of thumb when using C++. This is kind of a good practice rule that says that If your class needs any ofa copy constructor, an assignment operator, or a destructor, defined explicitly, then it is likely to need all three of them.Why is this? Its because, if your class requires any of the above, it is managing dynamically allocated resources and would likely be needing the other to successfully achieve that. For example, if you require an assignment operator, you would be creating copies of objects currently being copied by reference, hence allocating ... Read More

Why Using iostream eof in Loop Conditions is Considered Wrong

Nancy Den
Updated on 23-Jun-2020 13:40:06

203 Views

Just because we haven't reached the EOF, doesn't mean the next read will succeed.Consider you have a file that you read using file streams in C++. When writing a loop to read the file, if you are checking for stream.eof(), you're basically checking if the file has already reached eof. So you'd write the code like −Example#include #include using namespace std; int main() {    ifstream myFile("myfile.txt");    string x;        while(!myFile.eof()) {       myFile >> x;       // Need to check again if x is valid or eof       if(x) { ... Read More

Set Width of Outline Around Element with JavaScript

Swarali Sree
Updated on 23-Jun-2020 13:36:14

153 Views

To set the outline width, use the outlineWidth property. You can try to run the following code to set the width of the outline around an element with JavaScript −ExampleLive Demo                    #box {             width: 450px;             background-color: orange;             border: 3px solid red;             margin-left: 20px;          }                     Click below to add Outline Width. ... Read More

Set Outline Style Around an Element with JavaScript

Arushi
Updated on 23-Jun-2020 13:35:41

256 Views

To set the outline style, use the outlineStyle property. The outline can be solid, dotted, dashed, etc.ExampleYou can try to run the following code to set the style of the outline around an element with JavaScript −Live Demo                    #box {             width: 450px;             background-color: orange;             border: 3px solid red;             margin-left: 20px;          }                   ... Read More

Content Rendering Outside Element Box with JavaScript

karthikeya Boyini
Updated on 23-Jun-2020 13:35:09

255 Views

If the content renders outside the element box, use the overflow property to add a scroll. This will ease visitors in reading the entire content.ExampleYou can try to run the following code to learn how to work with overflow property in JavaScript −Live Demo                    #box {             width: 450px;             height: 150px;             background-color: orange;             border: 3px solid red;             margin-left: 20px;   ... Read More

Advertisements