C++编译器错误:"构造函数的返回类型规范无效"

Sun*_*nny 19 c++

这是我的代码.在编译所有文件时我得到了这个错误,我不确定我做错了什么.请指教.

Molecule.cpp:7:34:错误:构造函数的返回类型规范无效

//Sunny Pathak
//Molecule.cpp    
#include <iostream>
#include "Molecule.h"    
using namespace std;

inline void Molecule::Molecule(){
       int count;
       count = 0;
}//end function

bool Molecule::read(){
    cout << "Enter structure: %c\n" << structure << endl;
    cout << "Enter full name: %c\n" << name << endl;
    cout << "Enter weight   : %f\n" << weight << endl;
}//end function


void Molecule::display() const{
    cout << structure << ' ' << name << ' ' << weight << ' ' << endl;
}//end function
Run Code Online (Sandbox Code Playgroud)

jua*_*nza 24

构造函数没有返回类型:

class Molecule
{
 public:
  Molecule();  // constructor. No return type.
  bool read();
  void display() const;
};

Molecule::Molecule(){
       int count;
       count = 0;
}//end constructor
Run Code Online (Sandbox Code Playgroud)

还要注意,它count是构造函数体的局部,并且您没有使用它.