C++ is a statically-typed language, which means, you must specify the type of each variable during variable declaration.
In the above code snippet, we have concepts that resemble certain aspects of web development that might feel familiar. Just like in JavaScript, we use variables in C++ to store data. However, C++ is statically typed, so we need to declare the type of variable before we use it.
The string
keyword is used for string variable declarations, a similar concept in JavaScript. The variable webFramework
is assigned the value of React.js
, and favoriteAI
is assigned OpenAI
.
Moreover, the cout
statement is used for output, resembles console.log()
in JavaScript. In that line, we're essentially logging: 'My favorite web development framework is React.js and my favorite AI is OpenAI'. Even though the syntax is different, the paradigms of storing and outputting data are quite similar.
Hence, even though you're coming from a web development background, you'll find familiar concepts in C++, albeit with a few syntactical differences.
xxxxxxxxxx
using namespace std;
int main() {
string webFramework = "React.js";
string favoriteAI = "OpenAI";
cout << "My favorite web development framework is " << webFramework << " and my favorite AI is " << favoriteAI << endl;
return 0;
}