静态类,函数,值或其他(如果存在于c ++中) [英] Static Classes , Functions , values or others if exist in c++

查看:101
本文介绍了静态类,函数,值或其他(如果存在于c ++中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想知道关于c ++中静态事物的一切。我搜索了它,但大部分结果都是静态值!



我想知道静态类或函数,并创建它们的实例并使用它们的方法。



非常感谢亲爱的!

解决方案

在你写下这篇文章之前,你有没有看过你的学术书?问题?

有不同的来源,你可以找到静态类,函数和值。

确保你阅读

引用:

E. Balagurusamy

或浏览本网站以获取本书和详细研究。

http://books.google.com.np/books/about/Object_Oriented_Programming_With_C++.html?id=TN9wQjjDwp0C&redir_esc=y [ ^ ]

即使在此之后,如果您有更多疑问,那么您可以自由提问。

谢谢。


1)静态变量=全局变量但可见仅在目标函数或结构或类中。所以静态变量的值不是删除。



2)类或结构的静态成员=类的所有对象的全局变量。例如,对于类的count对象。



  class  MyClass { 
static int counter;
};





你可以致电



 MyClass :: counter ++; 


如果你真的想学习C ++那么这是开始的地方 [ ^ ]

Hi
I want to know everything about static things in c++ . I have searched it but most of results are about static values !

I want to know about static classes or functions and making an instance of them and approach to use them .

Thanks a lot dears!

解决方案

Did you go through you academic book before you write down this question?
there are different sources where you can find about the static class, function and values.
Make sure you go through the book of

Quote:

E. Balagurusamy

or go through this site to get this book and study in detail.
http://books.google.com.np/books/about/Object_Oriented_Programming_With_C++.html?id=TN9wQjjDwp0C&redir_esc=y[^]
Even after this, if you have got more queries then you are free to ask.
Thank you.


1) Static variable = global variable but visible only in target function or structure or class. So value of static variable is not delete.

2) Static member of class or structure = global variable for all objects of the class. For example for count objects of the class.

class MyClass{
 static int counter;
};



You can call

MyClass::counter++;


If you really want to learn about C++ then this is the place to start[^].


这篇关于静态类,函数,值或其他(如果存在于c ++中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆