[英]Explicit type is missing (int assumed)
我不明白我在做什么。 這是我使用標題,類和構造函數進行練習的一個非常簡單的程序。 它說我在Header2.cpp中沒有丟失函數getValue()的返回類型。 我不知道如何解決它。 有任何想法嗎?
測試文件
#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;
};
您缺少一個整數
int Thing::getValue()
{
return truthValue;
};
Thing::getValue()
{
return truthValue;
};
應該:
int Thing::getValue()
{
return truthValue;
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.