码迷,mamicode.com
首页 > 其他好文 > 详细

[RK_2014_1020]Cannot declare member function ‘static int Foo::bar()’ to have static linkage

时间:2014-10-20 19:24:37      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   for   strong   sp   2014   on   

1.

if you declare a method to be static in your .cc file.

The reason is that static means something different inside .cc files than in class declarations It is really stupid, but the keyword static has three different meanings. In the .cc file, the static keyword means that the function isn‘t visible to any code outside of that particular file.

This means that you shouldn‘t use static in a .cc file to define one-per-class methods and variables. Fortunately, you don‘t need it. In C++, you are not allowed to have static variables or static methods with the same name(s) as instance variables or instance methods. Therefore if you declare a variable or method as static in the class declaration, you don‘t need the static keyword in the definition. The compiler still knows that the variable/method is part of the class and not the instance.

 

2.本文网址[tom-and-jerry发布于2014-10-20 18:02]

http://www.cnblogs.com/tom-and-jerry/p/4037965.html 

[RK_2014_1020]Cannot declare member function ‘static int Foo::bar()’ to have static linkage

标签:blog   http   io   ar   for   strong   sp   2014   on   

原文地址:http://www.cnblogs.com/tom-and-jerry/p/4037965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!