【发布时间】:2018-04-11 20:58:09
【问题描述】:
我正在尝试创建一个对象,但显然它给构造函数带来了某种错误……什么? 我的代码如下所示:
#include <iostream>
#include "Pila.h"
#include "Functions.cpp"
#include <cstring>
using namespace std;
int error = 0;
class Hyogen{
private:
char *kozui;
int p_close;
int p_open;
int err_par, err_op, err_end, err_start;
public:
Hyogen(char *a);
bool Verify();
char *Elaborate();
void Errors();
};
Hyogen::Hyogen(char *a){
kozui = a;
err_par = 0;
err_op = 0;
err_end = 0;
err_start = 0;
p_close = 0;
p_open = 0;
}
bool Hyogen::Verify(){
for(int i=0;i<strlen(kozui);i++){
if(i == strlen(kozui)){
if(error != 0){
cout<<"uwu";
return false;
break;}
else{
cout<<"owo";
return true;}
}
check_parentesis(kozui, p_close, p_open);
if(p_close > p_open || p_open > p_close){
error++;
err_par++;
}
if(i == 0)
if(check_start_various(kozui)){
error++;
err_start++;
}
if(check_operator(kozui)){
if(check_mul_div(kozui))
break;
if(check_doubleop(kozui)){
error++;
err_op++;
}
}
if(i == strlen(kozui))
if(check_end_various(kozui)){
err_end++;
error++;
}
}
}
int main()
{
Hyogen koz;
char *espressione;
espressione = new char[50];
cout<<"Inserisci l'espressione: ";
cin>>espressione;
return 0;
}
我得到的错误如下:
main.cpp: In function ‘int main()’:
main.cpp:76:12: error: no matching function for call to ‘Hyogen::Hyogen()’
Hyogen koz;
^~~
main.cpp:20:1: note: candidate: Hyogen::Hyogen(char*)
Hyogen::Hyogen(char *a){
^~~~~~
main.cpp:20:1: note: candidate expects 1 argument, 0 provided
main.cpp:7:7: note: candidate: constexpr Hyogen::Hyogen(const Hyogen&)
class Hyogen{
^~~~~~
main.cpp:7:7: note: candidate expects 1 argument, 0 provided
main.cpp:7:7: note: candidate: constexpr Hyogen::Hyogen(Hyogen&&)
main.cpp:7:7: note: candidate expects 1 argument, 0 provided
发生了什么事?我需要做什么?似乎我必须在创建对象时提供一个参数,但是如何? (我需要通过“espressione”)
【问题讨论】:
-
但要解决您的问题,请将
Hyogen koz;移动到您获得输入的位置之后,然后更改为Hyogen koz(espressione); -
它仍然报错,我试过了:/ 编辑:它成功了,非常感谢!
标签: c++ arrays class compiler-errors