FAQ

how much do you know about C++ ?

let’s take a look,

BASIC

a Built-in Data-Type

int will store both types of value positive and negative numeric value.

char will store only a single character at a time while char[] store character of sequence like a string.

we can store numeric type value in a char data-type But a character type value will never store in a int data-type. learn more

We can store a mobile number using the modifier with int data-type (means long int) Because a mobile number has 10 digits and normal int cannot store such a large number. Learn more

  In simple language int can store values around 34000.

There is only major difference called OOPs. Learn more. 

Operator

called new line feed operator, used for next line as like in keyboard has enter button.

for dynamically memory allocation in C++.Learn more.

delete operator used to de-locate the memory, allocate by new operator in C++. Learn more.

== used in expression to check value is equal or not whereas = assign a value.

  • first To access the global variable when the local variable and global variable name are the same. see example
  • second use in the outside definition of function-members in structure and class.

to know data-type size in system. Learn more.

In reference variable and pointer. Learn more.

* asterisk called value of operator used to hold the address of varaible. Learn more.

in the array, to declare array-variable size. Learn more.

both are Logical type of operators, used for where we join more than one condition together. Learn more.

a type of realational operator name called by LESS THEN AND EQUAL TOLearn more.

arrow operator, used in pointer with structure and pointer with class to accessing their members.

control-statement

The selection statement consists of multiple blocks and each block executes one-time when the condition is true whereas in the looping-statement,
the body-of-loop is executed until the condition becomes false. meaning the body-of-loop repeats until the condition becomes false.

The parentheses bracket is optional for a single statement in the body of a control statement, such as in for-loop,
  for(intialization; expression; updation)
          Statement-1

But the parentheses bracket is used for multiple statements in the body.
for(intialization; expression; updation)
       {
           statement-1
           statement-2;
           statement-n;
       }

No, only int and char data-type may be used.

In both other loops, the first condition is checked, only when true, the body of loop is executed while in do-while
the first body of loop is executed and then the condition is checked. learn more.

breaking statement used to terminates an entire program or a single statement in a program. learn more.

exit(0), which is defined inside the stdlib.h header file. learn more.

The break-statement terminates the execution of the statement while the continue-statement skips the statement. learn more.

The break terminates a statement of the program while exit () terminates the entire program.

array

In a normal-variable, only one value can be stored at a time while in an array-variable multiple values of the same type can be stored at a time. learn more.

In normal-variable, 5 variables have to be declared (each variable for each number), while in array-variable only one array-variable size is 5 declare.

The character-array is always terminated by a null character, whereas the normal array has no such condition. so a normal-array will store as many elements as its size, whereas in a character-array, there will be 1 less element store than its size.

  •  char is a built in data type while array derived data type,
  • The char only store a single character at a time while the character array is a collection of char data type.

Not default. But this is possible using two way,

         Where an array-element is an object and as the collection of object data members and function members means different type of values.

  • Array size is of static type means we can no change array-size at run-time.
  • Array similar are data-type collections. Learn more.

Yes, we can change the array size at run-time using the dynamical memory management in C++.  Learn more.

structure/union

Array is a collection of similar data-types while structure is a collection of both similar and differential data-types. Learn more.

without structure-name structure will called anonymous structure. Here is the program below,

#include<iostream.h>
#include<conio.h>    

struct {
int num; } x;  

void main()
{ cout<<"Enter Number :"; cin>>x.num;  
getch();
}

In C++, structure members can be both types, data members and function members.

Using dot operator with structure-variable. Here is the syntex,

structure-variable.structure-member;

In c language, the member of a structure cannot be of function type whereas in C++ there is no such a condition. here is program.

When a structure is a variable declared. Only then does the structure take up space in memory. Learn more.

The memory size of a structure is equal to the total of the total sizes of its members.learn more.

all members of the structure by default are public while all members of the class by default are private. Learn more.

Yes,

#include<iostream.h>
#include<conio.h>
/
 struct construct
 {
    construct()
     {
       cout<<"constructor called";
     }
 };

 void main()
  {
   construct x;
   getch();
  }

but mostly it is not used. The reason is, that all members of the structure are by default public, so in a way there is no need for it.

The structure reserves all its members in a different memory-location in memory, while all members of the union are stored in the same location in memory. Learn more.

Because all members have the same memory address meaning all members are stored in the same location in memory. Learn more.

In a union, the member whose size is higher than other members will be the memory size of the union. here is program.