Sign in to follow this  
Followers 0
noatom

static variables name clash

3 posts in this topic

So I have an exercise in my book that says: prove that file static variables in header files don't clash with each other when included in more than one cpp file.

 

So I have a header file that contains just: int i=10;

and 2 cpp files that include that header file.

 

When i try to compile->fatal error LNK1169: one or more multiply defined symbols found

0

Share this post


Link to post
Share on other sites

Also, it's probably not a good idea to call a global variable "i". Such a variable name is very common for loops or other things.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0