I am sorry for that I have solved it, just missing a ";" when I define the class.
I have re-edited this thread.
So sorry for flippancy!

Dani AI

Generated

A common compiler cascade is visible here: the actual syntax fault was in a header, but the compiler complained in main.cpp. As pointed out (and confirmed), that pattern—messages like "new types may not be defined in a return type" or "two or more data types in declaration of ‘main’"—usually means the parser never saw a required token (most often the trailing semicolon after a class/struct/enum). The parser then tries to interpret the following source (often an included .cpp) as part of the malformed declaration, producing confusing errors and line numbers far from the real problem.

A minimal reminder of the correct form:

class Pigeon {
public:
    Pigeon();
    // members...
};  // <-- semicolon required

Checklist for diagnosing these cascade errors (matches and suggestions to inspect the files and post code when stuck):

  • Inspect the header(s) included by the file that shows the first error; look for missing ; after class/struct/enum or a missing }.
  • Compile with stricter diagnostics: g++ -Wall -Wextra -fsyntax-only main.cpp to get clearer parse failures.
  • Run the preprocessor (g++ -E main.cpp) or create a minimal reproducible file that includes only the suspect header to isolate the fault.
  • Check for stray macros or malformed templates that can hide missing punctuation.

These steps explain why the compiler pointed at main.cpp:4 even though the root cause was in the header, and provide a quick workflow to find similar problems in other projects.

Recommended Answers

All 4 Replies

Hello,my freinds:

I'm writing a program with Qt4.The program can communicate with each other in a LAN.
Now,may ererything be ok,but the constructor is wrong,the compiler tells the fallowing:

  1. main.cpp:4: error: new types may not be defined in a return type
  2. main.cpp:4: note: (perhaps a semicolon is missing after the definition of ‘Pigeon’)
  3. main.cpp:4: error: two or more data types in declaration of ‘main’

My Pigeon.cpp file includes the following sentences that implemente the constructor.

Well, since the error is in main() on line 4, maybe looking there will help.

line 30 of the header file needs a semicolon

Since the the errors refer to main.cpp, how about post that?

line 30 of the header file needs a semicolon

Yes,I am so sorry for that I haven't found it.
Just beacause it didn't note me find the errors in head file but in the .cpp file:'(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.