Jump to content

  • Log In with Google      Sign In   
  • Create Account

static variables name clash


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 noatom   Members   -  Reputation: 785

Like
0Likes
Like

Posted 31 March 2013 - 07:18 AM

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



Sponsor:

#2 Hodgman   Moderators   -  Reputation: 31822

Like
0Likes
Like

Posted 31 March 2013 - 07:24 AM

That should probably be static int i=10;



#3 Bacterius   Crossbones+   -  Reputation: 9281

Like
0Likes
Like

Posted 31 March 2013 - 07:26 AM

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.


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#4 noatom   Members   -  Reputation: 785

Like
0Likes
Like

Posted 31 March 2013 - 07:26 AM

yea...you are right...damn






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS