显式类型丢失(假设为int) [英] Explicit type is missing (int assumed)
本文介绍了显式类型丢失(假设为int)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不明白我做错了什么。这是一个非常简单的程序,我使用头文件,类和构造函数进行练习。它说我不缺少Header2.cpp中函数getValue()的返回类型。我不知道如何解决它。任何想法?
Test.cpp
#include< iostream> ;
#include< conio.h>
#includeHeader2.h
int main()
{
Thing Implement(1);
std :: cout<< 真值是:<< Implement.getValue()<< std :: flush<< / N 的;
_getch();
返回0;
}
Header2.h
#ifndef Object_H_
#define Object_H_
类Thing
{
public:
Thing(int a );
int getValue();
private:
int truthValue;
};
#endif // Object_H_
Header2.cpp
#include< iostream>
#includeHeader2.h
Thing :: Thing(int a)
{
if(a!= 0 || a!= 1)
{
std :: cout<< 不正确的真实价值。 <<的std ::冲洗;
}
else
{
truthValue = a;
}
};
Thing :: getValue()
{
return truthValue;
};
解决方案
您缺少 int
int Thing :: getValue()
{
return truthValue;
};
I don't get what I'm doing wrong. It's a really simple program I made to practice using headers, classes and constructors. It says that I'm not missing a return type for the function getValue() in Header2.cpp. I have no idea how to fix it. Any ideas?
Test.cpp
#include <iostream>
#include <conio.h>
#include "Header2.h"
int main()
{
Thing Implement(1);
std::cout << "The truth value is: " << Implement.getValue() << std::flush << "/n";
_getch();
return 0;
}
Header2.h
#ifndef Object_H_
#define Object_H_
class Thing
{
public:
Thing(int a);
int getValue();
private:
int truthValue;
};
#endif // Object_H_
Header2.cpp
#include <iostream>
#include "Header2.h"
Thing::Thing(int a)
{
if (a != 0 || a != 1)
{
std::cout << "Improper truth value." << std::flush;
}
else
{
truthValue = a;
}
};
Thing::getValue()
{
return truthValue;
};
解决方案
you are missing an int
int Thing::getValue()
{
return truthValue;
};
这篇关于显式类型丢失(假设为int)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文