Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ typeid

// C++ program to show the use of typeid operator
  
#include <iostream>
#include <typeinfo>
using namespace std;
  
int main()
{
    int i, j;
    char c;
  
    // Get the type info using typeid operator
    const type_info& ti1 = typeid(i);
    const type_info& ti2 = typeid(j);
    const type_info& ti3 = typeid(c);
  
    // Check if both types are same
    if (ti1 == ti2)
        cout << "i and j are of"
             << " similar type" << endl;
    else
        cout << "i and j are of"
             << " different type" << endl;
  
    // Check if both types are same
    if (ti2 == ti3)
        cout << "j and c are of"
             << " similar type" << endl;
    else
        cout << "j and c are of"
             << " different type" << endl;
  
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ template example 
Cpp :: max heap in c++ 
Cpp :: return array from function c++ 
Cpp :: find max value in array c++ 
Cpp :: c++ create multidimensional vector 
Cpp :: c++ prime sieve 
Cpp :: check uppercase c++ 
Cpp :: string to decimal c++ strtol 
Cpp :: convert string to lpstr 
Cpp :: c++ greatest common divisor 
Cpp :: C++ cin cout 
Cpp :: c vs c++ 
Cpp :: array max and minimum element c++ 
Cpp :: read and write file in c++ 
Cpp :: upcasting in c++ 
Cpp :: C++ String Length Example 
Cpp :: are strings mutable in c++ 
Cpp :: c++ cstring to string 
Cpp :: c++ string size 
Cpp :: built in function in c++ for binary to decimal 
Cpp :: prisma client 
Cpp :: how to convert ascii to char in cpp 
Cpp :: pragma cpp 
Cpp :: Find minimum maximum element CPP 
Cpp :: sum of row s2 d array c++ 
Cpp :: error handling in c++ 
Cpp :: c++ in cmd 
Cpp :: vector c++ 
Cpp :: print hello world c++ 
Cpp :: how to use a non const function from a const function 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =