小编Mar*_*ius的帖子

在'('标记之前)的预期构造函数,析构函数或类型转换

编译polygone.hpolygone.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)

c++ constructor class

12
推荐指数
2
解决办法
9万
查看次数

标签 统计

c++ ×1

class ×1

constructor ×1