Articles on Trending Technologies

Technical articles with clear explanations and examples

What are literals in C++?

Jai Janardhan
Jai Janardhan
Updated on 11-Feb-2020 788 Views

A literal is any notation for representing a value within the source code. They just exist in your source code and do not have any reference a value in memory. Contrast this with identifiers, which refer to a value in memory.There are several types of literals in C++. Some of the examples of literals are −"Hello" (a string)3.141 (a float/double)true (a boolean)3 (an integer)'c' (a character)Things that are not literals −bar = 0; (a statement)3*5-4 (an expression)std::cin (an identifier)

Read More

What is different between constant and variable in C++?

Samual Sam
Samual Sam
Updated on 11-Feb-2020 2K+ Views

Variable and constant are two commonly used mathematical concepts. Simply put, a variable is a value that is changing or that have the ability to change. A constant is a value which remains unchanged.For example, if you have a program that has a list of 10 radii and you want to calculate the area for all of these circles. To find the area of these circles, you'll write a program that will have a variable that will store the value of PI and this value will not change throughout the program. Such values can be declared as a constant.In the ...

Read More

What are different types of constants in C++?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 11-Feb-2020 892 Views

There are no types of constants in C++. It's just that you can declare any data type in C++ to be a constant. If a variable is declared as constant using the const keyword, you cannot reassign its value. Example#include using namespace std; int main() {    const int i = 5;    // Now all of these operations are illegal and    // will cause an error:    i = 10;    i *= 2;    i++;    i--;    //...    return 0; }

Read More

How to define constants in C++?

Arushi
Arushi
Updated on 11-Feb-2020 786 Views

You can define constants in C++ by adding the const qualifier before the declaration of the variable. Example#include using namespace std; int main() {    const int x = 9;    x = 0;    return 0; }This will define the constant variable x. But it will throw an error as we are trying to rewrite the value of a constant.

Read More

How to call an interface method in Java?

raja
raja
Updated on 11-Feb-2020 22K+ Views

In order to call an interface method from a java program, the program must instantiate the interface implementation program. A method can then be called using the implementation object.Examplepublic interface InterfaceDemo{     default public void displayNameDefault(String name){        System.out.println("Your name is : " + name);    }     public void displayName(String name);     public void displayNameAndDesignation(String name, String designation); }The above interface defines three methods for displaying a name and optionally a job title. One method is a default method that contains implementation logic. The remaining two methods do not include implementation logic.public class InterfaceDemoImpl ...

Read More

What is type inference in C++?

Samual Sam
Samual Sam
Updated on 11-Feb-2020 844 Views

Type inference or deduction refers to the automatic detection of the data type of an expression in a programming language. It is a feature present in some strongly statically typed languages. In C++, the auto keyword(added in C++ 11) is used for automatic type deduction. For example, you want to create an iterator to iterate over a vector, you can simply use auto for that purpose. Example#include #include using namespace std; int main() {    vector arr(10);    for(auto it = arr.begin(); it != arr.end(); it ++) {       cin >> *it;    }    return 0; }In the ...

Read More

How can we get the list of MySQL server-side help categories?

seetha
seetha
Updated on 11-Feb-2020 153 Views

We can get the list of MySQL server-side help categories by giving the keyword contents to the help command.mysql> help contents You asked for help about help category: "Contents" For more information, type 'help ', where is one of the following categories:    Account Management    Administration    Compound Statements    Data Definition    Data Manipulation    Data Types    Functions    Functions and Modifiers for Use with GROUP BY    Geographic Features    Help Metadata    Language Structure    Plugins    Procedures    Storage Engines    Table Maintenance    Transactions    User-Defined Functions    Utility

Read More

How do we initialize a variable in C++?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Feb-2020 260 Views

You can initialize a variable using the assignment operator or use its constructor when initializing it. For example,int i = 0; MyClass instance(1, "Hello");It will be automatically initialized ifIt's a class/struct instance in which the default constructor initializes all primitive types; like MyClass instance; You use array initializer syntax, e.g. int a[10] = {} (all zeroed) or int a[10] = {1,2}; (all zeroed except the first two items: a[0] == 1 and a[1] == 2) It is a global/extern variable It is defined static

Read More

What does a semicolon do after a C++ class name?

Swarali Sree
Swarali Sree
Updated on 11-Feb-2020 524 Views

If you have statements like −Class Person;This is a forward declaration. It lets the following code 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.

Read More

What is the difference between prefix and postfix operators in C++?

Smita Kapse
Smita Kapse
Updated on 11-Feb-2020 2K+ Views

In the prefix version (i.e., ++i), the value of i is incremented, and the value of the expression is the new value of i. So basically it first increments then assigns a value to the expression. In the postfix version (i.e., i++), the value of i is incremented, however, the {value|the worth} of the expression is that the original value of i. So basically it first assigns a value to expression and then increments the variable.Let's look at some code to get a better understanding −Example#include using namespace std; int main() {    int x = 3, y, z;   ...

Read More
Showing 52461–52470 of 61,248 articles
Advertisements