这个问题请教一下(我不知道咋描述)

吱吱吱吱涵 2015-07-28 04:04:42


如图所示,这个类最后,花括号外面的那个s是什么意思?

我不了解这个知识点,不知道怎么描述,所以没法百度

初学者,还望各位大大不吝赐教

...全文
92 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
勤奋的小游侠 2015-07-28
  • 打赏
  • 举报
回复
引用 3 楼 zzhhit2014 的回复:
[quote=引用 1 楼 JiangWenjie2014 的回复:] 类定义的同时,创建一个该类型的对象。
这个知识点属于哪一部分的?[/quote] 这是C语言的用法。 在声明结构体时同时定义一个结构体实例。在说结构体的那一章通常用这样的例子。
赵4老师 2015-07-28
  • 打赏
  • 举报
回复
查MSDN是Windows程序员必须掌握的技能之一。
吱吱吱吱涵 2015-07-28
  • 打赏
  • 举报
回复
引用 4 楼 zhao4zhong1 的回复:
class C++ Specific class [tag [: base-list ]] { member-list } [declarators]; [ class ] tag declarators; The class keyword declares a class type or defines an object of a class type. The elements of a class definition are as follows: tag Names the class type. The tag becomes a reserved word within the scope of the class. base-list Specifies the class(es) from which the class is derived (its base classes). Each base class's name can be preceded by an access specifier (public, private, protected) and the virtual keyword. See the Table of Member Access Privileges for more information. member-list Declares members or friends of the class. Members can include data, functions, nested classes, enums, bit fields, and type names. Friends can include functions or classes. Explicit data initialization is not allowed. A class type cannot contain itself as a nonstatic member. It can contain a pointer or a reference to itself. See the virtual keyword and the Table of Member Access Privileges for more information. declarators Declares one or more objects of the class type. END C++ Specific Example In the following example, the class CAboutDlg is derived from the base class CDialog. The new class contains one member function named CAboutDlg: // Example of the class keyword // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // Implementation protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //{{AFX_MSG(CAboutDlg) // No message handlers //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } For more information, see struct, union, __multiple_inheritance, __single_inheritance, and __virtual_inheritance.
万分感谢!!!
JiangWenjie2014 2015-07-28
  • 打赏
  • 举报
回复
引用 3 楼 zzhhit2014 的回复:
[quote=引用 1 楼 JiangWenjie2014 的回复:] 类定义的同时,创建一个该类型的对象。
这个知识点属于哪一部分的?[/quote] 不是很清楚,C语言里面就有这种用法了。

    int var0;

    struct {int x; int y;} var1;
int是类型,var0是标志符;struct {int x; int y;} 是类型,var1是标志符。这两者都是创建变量,没什么区别。
赵4老师 2015-07-28
  • 打赏
  • 举报
回复
class C++ Specific class [tag [: base-list ]] { member-list } [declarators]; [ class ] tag declarators; The class keyword declares a class type or defines an object of a class type. The elements of a class definition are as follows: tag Names the class type. The tag becomes a reserved word within the scope of the class. base-list Specifies the class(es) from which the class is derived (its base classes). Each base class's name can be preceded by an access specifier (public, private, protected) and the virtual keyword. See the Table of Member Access Privileges for more information. member-list Declares members or friends of the class. Members can include data, functions, nested classes, enums, bit fields, and type names. Friends can include functions or classes. Explicit data initialization is not allowed. A class type cannot contain itself as a nonstatic member. It can contain a pointer or a reference to itself. See the virtual keyword and the Table of Member Access Privileges for more information. declarators Declares one or more objects of the class type. END C++ Specific Example In the following example, the class CAboutDlg is derived from the base class CDialog. The new class contains one member function named CAboutDlg: // Example of the class keyword // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // Implementation protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //{{AFX_MSG(CAboutDlg) // No message handlers //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } For more information, see struct, union, __multiple_inheritance, __single_inheritance, and __virtual_inheritance.
吱吱吱吱涵 2015-07-28
  • 打赏
  • 举报
回复
引用 1 楼 JiangWenjie2014 的回复:
类定义的同时,创建一个该类型的对象。
这个知识点属于哪一部分的?
cobra_chen 2015-07-28
  • 打赏
  • 举报
回复
S是一个变量,是Sales_staff_List的对象。 可以用S.n或S.fileOutput()
JiangWenjie2014 2015-07-28
  • 打赏
  • 举报
回复
类定义的同时,创建一个该类型的对象。

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧