编译polygone.h并polygone.cc给出错误:
polygone.cc:5:19: error: expected constructor, destructor, or type conversion before ‘(’ token
Run Code Online (Sandbox Code Playgroud)
码:
//polygone.h
# if !defined(__POLYGONE_H__)
# define __POLYGONE_H__
# include <iostream>
class Polygone {
public:
Polygone(){};
Polygone(std::string fichier);
};
# endif
Run Code Online (Sandbox Code Playgroud)
和
//polygone.cc
# include <iostream>
# include <fstream>
# include "polygone.h"
Polygone::Polygone(string nom)
{
std::ifstream fichier (nom, ios::in);
std::string line;
if (fichier.is_open())
{
while ( fichier.good() )
{
getline (fichier, line);
std::cout << line << std::endl;
}
}
else
{
std::cerr << "Erreur …Run Code Online (Sandbox Code Playgroud)