Undefined reference to projectControl::get_defprojloc()

I'm receiving a "undefined reference to 'projectControl:get_defprojloc()'" with the following code...

projectcontrol.h

1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef PROJECTCONTROL_H
#define PROJECTCONTROL_H
#include "string"

class projectControl
{
public:
    projectControl();
    std::string get_defprojloc();
    std::string get_defprojfolder();
};

#endif // PROJECTCONTROL_H 


projectcontrol.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <QApplication>
#include <projectcontrol.h>
#include <string>

std::string mdk_defProjLoc = "";

std::string mdk_defProjFolder = "";

projectControl::projectControl()
{

}

std::string get_defprojloc() {
    return mdk_defProjLoc;
}
void set_defprojloc(std::string newloc) {
    mdk_defProjLoc = newloc;
}
std::string get_defprojfolder() {
    return mdk_defProjFolder;
}
void set_defprojfolder(std::string newloc) {
    mdk_defProjFolder = newloc;
}


splashscreen.cpp (I get the error in this source file on line 22)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "splashscreen.h"
#include "ui_splashscreen.h"
#include "projectcontrol.h"
#include "QKeyEvent"

splashScreen::splashScreen(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::splashScreen)
{
    ui->setupUi(this);

}

splashScreen::~splashScreen()
{
    delete ui;
}

void splashScreen::keyPressEvent(QKeyEvent *event) {
    if (event->key() == Qt::Key_Alt) {
        projectControl *projCntrl = new projectControl();
        std::string str_test = projCntrl->get_defprojloc();
    }
}


What do i do to get rid of the error? I've been to two other forum posts about a similar issue but they did not solve the error.
Your implementation of get_defprojloc is in your global name space, and is not a member of projectControl. It should be:
 
std::string projectControl::get_defprojloc() 


set_defprojloc, get_defprojfolder, set_defprojfolder have the same issue.
Last edited on
Thanks AbstractionAnon, that fixed my problem.

I appreciate it!
Topic archived. No new replies allowed.