我不明白我做错了什么。这是我用来练习使用头、类和构造器的一个非常简单的程序。这说明我没有遗漏Header2.cpp中函数getValue()的返回类型。我不知道如何修复它。有什么想法吗?
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;
};发布于 2013-11-11 08:57:37
您缺少一个int
int Thing::getValue()
{
return truthValue;
};发布于 2013-11-11 08:56:58
Thing::getValue()
{
return truthValue;
};应该是:
int Thing::getValue()
{
return truthValue;
};https://stackoverflow.com/questions/19897243
复制相似问题