Jump to content
  • Advertisement
Sign in to follow this  
Ultima79

dont know what's wrong

This topic is 4994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, so I have a function called isNum which is used by some of my classes and my main cpp so i decided to make it into a .h file so i did and i included it at the top of every file that uses isNum since it wont compile if i dont. the problem is it now says i have one or more multiply defined symbols for isNum. some one please help i am working with VC++ 6

Share this post


Link to post
Share on other sites
Advertisement
Use #ifndef/#define/#endif. #pragma once is compiler specific.

Like this:
// blah.h
#ifndef _BLAH_H_
#define _BLAH_H_

// code here

#endif



-RC

Edit: since you're using MSVC, #pragma once should work just fine. If #pragma once isn't working, something else is wrong, and we probably can't help you without more information.
Edit again: does the compiler complain, or does the linker? If it's the linker, then you need to make sure you have the declaration in the header file and the implementation somewhere else.

Share this post


Link to post
Share on other sites
that's what i have actually
here is what i've done in case it helps


//strops.h
#ifndef STROPS_H
#define STROPS_H

bool isNum(...)
{...}

#endif




//someclass.h
#ifndef SOMECLASS
#define SOMECLASS
class someClass
{
void doSomething();
};
#endif




//someclass.cpp
#include "someclass.h"
#include "strops.h"

void someClass::doSomething()
{
...
isNum(...)
...
}





//main.cpp
#include <iostream>
#include "strops.h"
using namespace std;

int main()
{
...
isNum(...)
...
return 0;
}


Share this post


Link to post
Share on other sites
That's what I thought. Here's what I meant by my second edit:


//strops.h
#ifndef STROPS_H
#define STROPS_H

bool isNum(...);

#endif




//strops.cpp
#include "strops.h"

bool isNum(...)
{...}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!