Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Compiler/linker complaining about function definition not found in C++

I’ve done this so many times, yet the reason why Visual Studio is complaining about this escapes me.

Manipulator.cpp:

#include "Manipulator.h"

Manipulator::Manipulator() {}
Manipulator::~Manipulator() {}


void proc(std::string p, int f, std::string c)
{
    // switch-case p to c based on f: 

    return;
}

Manipulator.h: (void -proc- has a curly underscore, and that’s what’s driving me up the wall.)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

#ifndef MANIPULATOR_H
#define MANIPULATOR_H
#include <string>

class Manipulator
{
private:

protected:

public:
    Manipulator() ;
    ~Manipulator() ;

    void proc(std::string, int, std::string);
    // function definition for 'proc' not found. 

};

#endif MANIPULATOR_H

main.cpp

#include "Manipulator.h"
...
int main() 
{
    ...
    Manipulator m; 
    ...
    m.proc(opdBMP, fxn, newBMP); 

    return 0; 
}

What is it that VS wants so that I can get a move on? It is telling me that there are two linker errors: LNK2019 and LNK1120 (unresolved external). (I used to keep track of these kinds of errors but lost the file as a log with these.)

>Solution :

The compiler is correct in complaining, because the definition should be

void Manipulator::proc(std::string p, int f, std::string c) {
...
}

You just defined a free function instead of a member of Manipulator.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading