Why doesn't the following c++ code work?
#include <iostream> #include <vector> using namespace std; typedef string string_t; typedef int Nummer_t int main () { string_t Name = "Frank"; cout << Name; Nummer_t x; x = 5; cout << x * x; return 0; }
Apparently the error is in int main () { but I don't see any.
Error message from the compiler: 6 | int main () {
| ^~~
Missing semicolon after typedef-statement.
In case of error messages from the compiler you should always look into the surrounding area. He can’t always guess perfectly what you actually wanted to achieve.
Thank you.
In the case of Typedef number, this is missing;
Thank you.
No problem
string_t Name = “Frank”;
comes to me a little strange because you only defined string_t as a string.
The variable name just pops up below
Where should the Frank get, in string_t or name ?
In the following code, it should be an exercise, when using typedef, so it is a bit unclear with string_t.
Frank is supposed to be a name.
have a little googled by examples
https://learn.microsoft.com/de-de/cpp/cpp/aliases-and-typedefs-cpp?view=msvc-170#example
after which I suspect that
name string_t = “Frank”;
name should be read as string_t defined