how do i use a function without calling it from a different class? (i have more files in my project)
i made a test function called dostuff() { } inside some random file outside a class. but when i want to compile i get this:

Error 1 error LNK2005: "void __cdecl dostuff(void)" (?dostuff@@YAXXZ) already defined in YAGP.obj N_MenuButton.obj

The error makes it sound like you're trying to redefine the function in your main file. You need to declare an instance of a class to use the functions in it.

well thats what i don't want to do. i want to use a function that isn't inside a class. lets say this is the case:

class blbl
{
some random things, not important now
};

void foo(some stuff)
{

}

i want to use foo in some other .cpp file or whatever. i get this error altough there are no other functions with that name (?)

ugh some error, dont mind this post, it double posted

nvm i got it to work now. i just used the static keyword

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.