In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
The editor of this article introduces "how to customize classes in C++" in detail. The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to customize classes in C++" can help you solve your doubts. Let's follow the editor's ideas to slowly deepen, let's learn new knowledge.
The code is as follows:
/ TestClass.h/
Class TestClass
{
Public:
Void Test ()
Int a
Private:
Int b
Public:
Static int c
/ / Don't forget to take this semicolon with you, or the following cpp will indicate that namespace is missing a semicolon.
/ C++BaseTest.cpp////
# include "stdafx.h"
# include "TestClass.h"
# include
Using namespace std
TestClass tc
/ / tc.a = 10
/ / tc.b = 30
/ / you will find that an error will be reported when initializing a member variable of TestClass as a global variable, and the reason remains to be studied.
Int TestClass::c = 8
The static variable of the / / class, the definition does not need to be preceded by static, otherwise an error will be reported. It serves as a shared value for all class objects.
Void TestClass::Test ()
{
Baked 20
Cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.