1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>
int main() {
int x = 5;
std::string s = "Hello";
// Uncommenting the next line will cause a compile-time error
// x = s; // Error: cannot assign std::string to int
std::cout << "x = " << x << std::endl;
std::cout << "s = " << s << std::endl;
return 0;
}
Back to type_safety