Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 对`PPM::PPM()的未定义引用找不到我出现此错误的原因_C++ - Fatal编程技术网

C++ 对`PPM::PPM()的未定义引用找不到我出现此错误的原因

C++ 对`PPM::PPM()的未定义引用找不到我出现此错误的原因,c++,C++,因此,尽管我正确地调用了这个类,但如果有人能提供帮助,我还是不断地遇到这个错误 void PPM::sepiaFilter( PPM& dst ) const { dst.setWidth( this->getWidth( ) ); dst.setHeight( this->getHeight( ) ); dst.setMaxColorValue( this->getMaxColorValue( ) ); double red =

因此,尽管我正确地调用了这个类,但如果有人能提供帮助,我还是不断地遇到这个错误

void PPM::sepiaFilter( PPM& dst ) const {

    dst.setWidth( this->getWidth( ) );

    dst.setHeight( this->getHeight( ) );

    dst.setMaxColorValue( this->getMaxColorValue( ) );

    double red = 0;

    double green = 0;

    double blue = 0;

    for ( int y = 0; y <= this->getHeight( ); y++ ) {

        for ( int x = 0; x <= this->getWidth( ); x++ ) {

            red = this->getChannel( y, x, 0 );

            green = this->getChannel( y, x, 1 );

            blue = this->getChannel( y, x, 2 );

            double new_red = 0.393 * red + 0.769 * green + 0.189 * blue;

            double new_green = 0.349 * red + 0.686 * green + 0.168 * blue;

            double new_blue = 0.272 * red + 0.534 * green + 0.131 * blue;

            if ( new_red > this->getMaxColorValue( ) ) {

                dst.setChannel( y, x, 0, this->getMaxColorValue( ) );

            }

            if ( new_green > this->getMaxColorValue( ) ) {

                dst.setChannel( y, x, 1, this->getMaxColorValue( ) );

            }

            if ( new_blue > this->getMaxColorValue( ) ) {

                dst.setChannel( y, x, 2, this->getMaxColorValue( ) );

            }

            dst.setChannel( y, x, 0, int ( new_red ) );

            dst.setChannel( y, x, 1, int ( new_green ) );

            dst.setChannel( y, x, 2, int ( new_blue ) );

        }

    }

}
void PPM::sepiaFilter(PPM&dst)常量{
setWidth(this->getWidth());
setHeight(this->getHeight());
setMaxColorValue(this->getMaxColorValue());
双红=0;
双绿=0;
双蓝=0;
对于(int y=0;y getHeight();y++){
对于(int x=0;x getWidth();x++){
红色=此->获取通道(y,x,0);
绿色=此->获取通道(y,x,1);
蓝色=此->获取通道(y,x,2);
双新_红=0.393*红+0.769*绿+0.189*蓝;
双新_绿=0.349*红+0.686*绿+0.168*蓝;
双新_蓝=0.272*红+0.534*绿+0.131*蓝;
if(new\u red>this->getMaxColorValue()){
setChannel(y,x,0,this->getMaxColorValue());
}
if(new_green>this->getMaxColorValue()){
setChannel(y,x,1,this->getMaxColorValue());
}
if(new_blue>this->getMaxColorValue()){
setChannel(y,x,2,this->getMaxColorValue());
}
dst.setChannel(y,x,0,int(新的红色));
dst.setChannel(y,x,1,int(新绿色));
dst.setChannel(y,x,2,int(新蓝色));
}
}
}
不管我做什么,即使一切看起来都是正确的,我还是不断地犯这个错误。我已经改变了很多东西,使它不会抛出错误,我只是继续抛出相同的错误。如果有人能帮我找到现在的处境,那么我可以很高兴地继续我的生活

这是我的.h文件

#ifndef _PPM_H_
#define _PPM_H_


#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>


class PPM {


public:

    PPM( );

    int getWidth( ) const;

    int getHeight( ) const;

    int getMaxColorValue( ) const;

    int getChannel( const int& row, const int& column, const int& channel ) const;

    void setWidth( const int& width );

    void setHeight( const int& height );

    void setMaxColorValue( const int& max_color_value );

    void setChannel( const int& row, const int& column, const int& channel, const int& value );

    int getting_width;

    int rhs_width;

    int rhs;

    int lhs;

    bool operator<(const PPM& rhs);

    bool operator>(const PPM& rhs);

    bool operator==(const PPM& rhs);

    bool operator<=(const PPM& rhs);

    bool operator>=(const PPM& rhs);

    bool operator!=(const PPM& rhs);

    PPM operator+=(const PPM& rhs);

    PPM operator-=(const PPM& rhs);

    PPM operator+(const PPM& rhs) const;

    PPM operator-(const PPM& rhs) const;

    PPM operator*(const PPM& rhs) const;

    PPM operator*=(double d);

    PPM operator/=(double d);

    PPM operator*(double d) const;

    PPM operator/(double d) const;

    void sepiaFilter( PPM& dst ) const;


private:

    int mWidth;

    int mHeight;

    int mMAX_COLOR;

    int mRow;

    int mColumn;

    int mChannel;

    std::vector < int > Pixel;

};

std::ostream& operator << (std::ostream& output, const PPM& Pic_out);

std::istream& operator >> (std::istream &input, PPM& Pic_in);

#endif /* _PPM_H_ */
\ifndef\u PPM\u H_
#定义_PPM_H_
#包括
#包括
#包括
#包括
#包括
#包括
#包括
类PPM{
公众:
PPM();
int getWidth()常量;
int getHeight()常量;
int getMaxColorValue()常量;
int getChannel(常量int和行、常量int和列、常量int和通道)常量;
void setWidth(const int&width);
空隙设置高度(常数内部和高度);
void setMaxColorValue(常量int和最大颜色值);
void setChannel(常量int和行、常量int和列、常量int和通道、常量int和值);
整型,宽度;
int rhs_宽度;
int rhs;
内部lhs;
bool操作员(常量PPM和rhs);
布尔运算符==(常量PPM和rhs);
布尔运算符=(常量PPM和rhs);
布尔运算符!=(常量PPM和rhs);
PPM运算符+=(常量PPM和rhs);
PPM运算符-=(常量PPM和rhs);
PPM操作员+(常量PPM和rhs)常量;
PPM操作员-(常量PPM和rhs)常量;
PPM操作员*(常量PPM和rhs)常量;
PPM运算符*=(双d);
PPM运算符/=(双d);
PPM运算符*(双d)常数;
PPM运算符/(双d)常数;
真空紫褐色过滤器(PPM和dst)常数;
私人:
国际宽度;
整数mHeight;
int mMAX_颜色;
int mRow;
int mColumn;
int mChannel;
std::向量像素;
};
std::ostream&operator>(std::istream&input、PPM&Pic_in);
#endif/*\u PPM\u H\u*/

您是否在类中实现了构造函数?您必须在.h或cpp文件中需要一个构造函数体

我在任何地方都看不到构造函数体。。。您至少应该在构造函数内部或在类本身内部初始化私有变量的所有值。。。如果您决定在类内初始化它们,那么只需将构造函数声明为
PPM()=default。。。(将与C++11及以上版本一起使用)是的,我完全错过了.cpp文件开头的构造函数。非常感谢。对我来说,这更像是一个评论而不是一个答案。。。