1
votes

I'm totally lost on this one.

When compiling, i get this error :

Error 7 error LNK1120: 6 unresolved externals

Error 4 error LNK2001: unresolved external symbol "public: double __thiscall Cmyk::getB2(void)" (?getB2@Cmyk@@QAENXZ)

Error 5 error LNK2001: unresolved external symbol "public: double __thiscall Cmyk::getG(void)" (?getG@Cmyk@@QAENXZ)

Error 6 error LNK2001: unresolved external symbol "public: double __thiscall Cmyk::getR(void)" (?getR@Cmyk@@QAENXZ)

Error 1 error LNK2001: unresolved external symbol "public: double __thiscall Hex::getB2(void)" (?getB2@Hex@@QAENXZ)

Error 2 error LNK2001: unresolved external symbol "public: double __thiscall Hex::getG(void)" (?getG@Hex@@QAENXZ)

Error 3 error LNK2001: unresolved external symbol "public: double __thiscall Hex::getR(void)" (?getR@Hex@@QAENXZ)

Here's the code

#ifndef header_h_
#define header_h_


 class Spalva
 {
  public:
  double r, g, b2, c2;

  public:
  Spalva(){}
  Spalva(double a, double b, double c, double c2)
  {

   }
  };


  class Spalva2 :public Spalva {



  public:
    Spalva2();
    Spalva2(int a, int b, int c);

    double getR();
    double getG();
    double getB2();



     Spalva2 operator+(Spalva2 a);
     void print();

    };

   class Hex :public Spalva {


   public:
     Hex();
     Hex(int a, int b, int c);


    void hex1();
    void hex2();
    void hex3();

    double getR();
   double getG();
   double getB2();


 };

 class Cmyk :public Spalva {


public:
  Cmyk();
  Cmyk(double a, double b, double c, double d);

   double getR();
   double getG();
   double getB2();


   void cmyk();

};





#endif // header_h_

And .cpp file

   #include <iostream>
   #include <iomanip>
   #include <stdio.h>
   #include <stdlib.h>
   #pragma warning(disable : 4996)
   #pragma warning(disable : 4244)
   #include "header.h"

   using namespace std;


  Spalva2::Spalva2() {};
  Spalva2 :: Spalva2(int a, int b, int c) {
     r = a;
     g = b;
     b2 = c;

}



Spalva2 Spalva2 :: operator+(Spalva2 a) {
    Spalva2 rez;

    if (r == 255 && g == 255 && b2 == 255 &&
        a.getR() == 255 && a.getG() == 255 && a.getB2() == 255)
    {
        rez.r = 255;
        rez.g = 255;
        rez.b2 = 255;
        cout << "Nauja RGB spalva:" << endl;
        return rez;
    }

    if (r == 1 && g == 1 && b2 == 1 &&
        a.getR() == 1 && a.getG() == 1 && a.getB2() == 1)
    {
        rez.r = 1;
        rez.g = 1;
        rez.b2 = 1;
        cout << "Nauja RGB spalva:" << endl;
        return rez;
    }


    rez.r =  this->r / 2 + a.getR() / 2;
    rez.g = this->g / 2 + a.getG() / 2;
    rez.b2 = this->b2 / 2 + a.getB2() / 2;

    cout << "Nauja RGB spalva:" << endl;
    return rez;
}
 void Spalva2 ::  print() {

    cout << getR() << " " << getG() << " " << getB2() << endl;

}



Hex :: Hex() {};
Hex :: Hex(int a, int b, int c) {
    r = a;
    g = b;
    b2 = c;
}


void Hex :: hex1()
{

    char buffer[33];
    cout << "HEX: #" << setw(2) << setfill('0') << itoa(getR(), buffer, 16);
}
void Hex :: hex2()
{
    char buffer[33];
    cout << setw(2) << setfill('0') << itoa(getG(), buffer, 16);
}

void Hex :: hex3()
{
    char buffer[33];
    cout << setw(2) << setfill('0') << itoa(getB2(), buffer, 16) << endl;
}






Cmyk::Cmyk() {}
Cmyk::Cmyk(double a, double b, double c, double d) {
    r = a;
    g = b;
    b2 = c;
    c2 = d;
}

 double Spalva2 :: getR() {
    return this->r;
}
 double Spalva2 :: getG() {
    return this->g;
}
 double Spalva2 :: getB2() {
    return this->b2;
}

void Cmyk :: cmyk()
{
    double max, temp1, temp2, temp3;


    Cmyk rez;

    temp1 = getR() / 255;
    temp2 = getG() / 255;
    temp3 = getB2() / 255;

    max = temp1;

    if (temp2 > max)
        max = temp2;
    if (temp3 > max)
        max = temp3;


    rez.c2 = 1 - max;
    rez.r = (1 - temp1 - rez.c2) / (1 - rez.c2);
    rez.g = (1 - temp2 - rez.c2) / (1 - rez.c2);
    rez.b2 = (1 - temp3 - rez.c2) / (1 - rez.c2);



    cout << fixed << setprecision(3) << "C: " << rez.r << " M: " << rez.g << " Y: " << rez.b2 << " K: " << rez.c2 << endl;



}

Any help appreciated :)

1

1 Answers

3
votes

You forgot implement some methods. For example you have no implementation for methods: double getR();, double getG();, double getB2(); in CPP file. The same for Cmyk class.