相关疑难解决方法(0)

缺少显式类型(假设为int)

我不知道我做错了什么.这是一个非常简单的程序,我使用标题,类和构造函数来练习.它说我没有错过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;
}
Run Code Online (Sandbox Code Playgroud)

Header2.h

#ifndef Object_H_
#define Object_H_

class Thing
{
public:
    Thing(int a);

int getValue();
private:
int truthValue;
};

#endif // Object_H_
Run Code Online (Sandbox Code Playgroud)

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; …
Run Code Online (Sandbox Code Playgroud)

c++ constructor header class

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×1

class ×1

constructor ×1

header ×1