Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) data type

 

A data type is the form that data (for example: numbers, words, images) has. Every variable has a data type. C++ is type safe, which means that during compiling it checks that all conversions are legal.

 

The example below the definition of a variable of data type double with the name of 'd' being assigned the value 3.1415. The next line tries to assign the text 'hello world' to d, which is illegal, because 'hello world' if not of data type double (but of std::string).

 

int main()
{
  double d = 3.1415; //Legal
  d = "hello world"; //ILLEGAL!
}

 

Use a consistent method (such as uppercase first letter) to distinguish type names [1].

 

 

 

 

 

List of data types that are also keywords

 

Some data types are only accepted by some standards:

 

  1. C++98C++11 bool
  2. C++98C++11 char
  3.  C++11 char16_t
  4.  C++11 char32_t
  5. C++98C++11 double
  6. C++98C++11 float
  7. C++98C++11 int
  8. C++98C++11 long
  9. C++98C++11 long long int
  10. C++98C++11 short
  11. C++98C++11 void (in the form of void*)
  12. C++98C++11 wchar_t

 

The range of each of these data types can be found with std::numeric_limits.

 

 

 

 

 

List of data types that are not keywords (incomplete)

 

This list will never be complete and is just a colorful collection of classes.

 

  1. boost::regex
  2. cln::cl_I
  3. Flood::MultilayerPerceptron
  4. HugeVector
  5. QLabel
  6. std::string
  7. std::vector

 

 

 

 

 

References

 

  1. John Lakos. Large-Scale C++ Software Design. 1996. ISBN: 0-201-63362-0. Chapter 2.7: 'Use a consistent method (such as uppercase first letter) to distinguish type names'

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict