0

I spent the day looking at similar errors online, but I'm still having trouble understanding how it applies to my project.

I'll post a full-class simplified version of the program.

I have a header file with some static methods in it:

#pragma once

class A {
public:
    static void function_a1(float &var_1);
    static void function_a2(float &var_1);
}

I also have a .cpp file which defines the methods:

#include "A.h"

void A::function_a1(float &var_1) {
    ...
}

void A::function_a2(float &var_1) {
    ...
}

The functions are meant to modify the variables I send through. I'm trying to call them within my main.cpp file:

#include "A.h"

using namespace std;

void main() {
    float x = 1.0f;
    float y = 2.4f;

    A::function_a1(x);
    A::function_a2(y);
}

But this doesn't build, instead telling me that A::function_a1(&float) and A::function_a2(&float) are unresolved external symbols. I'm not used to C++, so am I using statics wrong? How would I go about fixing this?

I'm definitely sending through the correct variables - the functions within A.h used to be within my main.cpp and I'm trying to move them over to a separate file.

I saw the post that this is a "duplicate" of, but I can't figure out how to apply any of those answers to my question.

  • FYI, you're missing `public:` from your example. Could you please post code that is [a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) so we don't have to guess what is wrong with the code in your example versus what is wrong with the code _you're really using_. – James Adkison Mar 12 '16 at 21:00
  • Yes, you're right. Sorry about that! If this helps, the code doesn't cause any errors within Visual Studio until I try to compile it. – Marcel Troscianko Mar 12 '16 at 21:03
  • 1
    Alright, it's fixed. I'd say I fixed it, but all I did was launch it again. And no, it didn't work when I cleaned/rebuilt it. It just worked an arbitrary time later... – Marcel Troscianko Mar 12 '16 at 21:24

0 Answers0