. Advertisement .
..3..
. Advertisement .
..4..
Hi expert. I’m writing these words to ask for everyone’s help. I get the message: iso c++ forbids declaration of with no type, but I don’t know the way to fix it.
[Admin@shadowrealm ircservices]$ g++ main.cpp -o services
In file included from main.cpp:1:0:
services.h:8:15: error: ISO C++ forbids declaration of âserivcesâ with no type [-fpermissive]
used by the compiler (with g++)
main.cpp:
#include "services.h"
#include <iostream>
using namespace std;
int main(int ac, char **av)
{
services myservices;
if(myservices.startup() == 1)
cout << "Cool this works!!" << endl;
return(0);
}
services.h:
#ifndef SERVICES_H
#define SERVICES_H
class services
{
public:
serivces();
~services();
int startup();
};
#endif
services.cpp:
#include "services.h"
services::services()
{
}
services::~services()
{
}
int services::startup()
{
return 1;
}
Please help me. Thank you very much.
The cause:
In response to your second update,
This is the cause of your issue: iso c++ forbids declaration of with no type. You likely overlooked the creation of the
object
file, which is a compilation step:Solution:
Step 1:
This will produce the object file which you can do for linking, the final step:
Since you were essentially pasting the complete code into the main during pre-processing, including the
.cpp
files in the main fixes the issue.