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 () {

| ^~~

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
8 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
jo135
1 year ago
typedef int Nummer_t

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.

Fab1anDev
1 year ago

In the case of Typedef number, this is missing;

Fab1anDev
1 year ago
Reply to  MrRandom898

No problem

newcomer
1 year ago

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 ?

newcomer
1 year ago
Reply to  MrRandom898

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