c ++类成员函数_C ++ | 创建一个空类(没有数据成员和成员函数的类)

news/2024/7/20 2:35:01 标签: c++, python, java, 小程序, mysql

c ++类成员函数

In the below program, we are creating a C++ program to create an empty class (a class without data members and member functions).

在下面的程序中,我们正在创建一个C ++程序来创建一个空类(一个没有数据成员和成员函数的类)

#include <iostream>

using namespace std;

// class definition
class Person {};

// main function
int main() {
  //object creation
  Person per;
  
  // here - we are printing size of the object
  cout << "size of per: " << sizeof(per) << endl;
  
  return 0;
}

Output

输出量

size of per: 1

See the program – here class named Person doesn't have any data member and member function – it will be known as an empty class.

请参阅程序-这里名为Person的类没有任何数据成员和成员函数-将被称为空类

翻译自: https://www.includehelp.com/cpp-programs/create-an-empty-class-a-class-without-data-members-and-member-functions.aspx

c ++类成员函数


http://www.niftyadmin.cn/n/1253743.html

相关文章

Haproxy+Nginx

主 dd从 dd1 dd2 #从dd1 dd2同配置useradd -M -s /sbin/logoin nginx./configure \-prefix/usr/local/nginx \-usernginx \-groupnginxmake&&make installln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/echo "<h1>SERVER1</h1>">/usr/l…

python打印变量类型_Python | 声明不同类型的变量,打印其值,类型和ID

python打印变量类型Declare different types of variables; print their types, ids and variables in Python. 声明不同类型的变量&#xff1b; 在Python中打印其类型&#xff0c;id和变量。 There are two inbuilt functions are using in the program: 程序中使用了两个内置…

最长回文子串的求解(java)

根据时间复杂度区别方法&#xff1a; 1、O(n3) 暴力破解 step&#xff1a;首先遍历出所有子串&#xff0c;然后针对每一个子串都判断一下是否为回文子串&#xff0c;是的话判断是否为最长的回文串。 2、O(n2) 中心扩展 step&#xff1a;遍历字符串的每一个字符&#xff0c;以之…

小程序自定义单个页面标题栏_在单个Java程序中使用所有用户定义的异常关键字...

小程序自定义单个页面标题栏As we know that Java provides an efficient mechanism for handling the exception but still user has the option to define its own exception in Java, using try-catch blocks or using throw keyword. List of various user-defined excepti…

0.1+0.2!==0.3

因为机器只能识别2进制&#xff0c;所以结果是一个无限接近0.3的数字0.30000000000000004 那怎么处理这种情况&#xff1a; ES6中提供了这样一个属性&#xff1a;Number.EPSILON&#xff0c;而这个值正等于2^-52&#xff0c;这个值非常非常小&#xff0c;并且无限接近0&#xf…

finalize java_受保护的Java对象类void finalize()抛出带有示例的Throwable方法

finalize java受保护的对象类void finalize()引发Throwable (Object Class protected void finalize() throws Throwable) This method is available in java.lang.Object.finalize(). 此方法在java.lang.Object.finalize()中可用。 This method is called by the garbage coll…

django 自定义auth中user登陆认证以及自写认证

第一种&#xff1a; 重写自定义auth中user登陆认证模块&#xff0c; 引入MobelBackend from django.contrib.auth.backends import ModelBackend 重写验证模块 class CustomBackend(ModelBackend):def authenticate(self, request, usernameNone, passwordNone, **kwargs):try:…

pgm模型_PGM的应用以及贝叶斯和马尔可夫模型的关系和转换

pgm模型PGM的应用&#xff1a;(用例) (Application of PGMs: (Use cases)) Netflix, Amazon, facebook all use PGM recommend what is best for you. Netflix&#xff0c;Amazon&#xff0c;facebook都使用PGM推荐最适合您的。 This algorithm, Use the latent factor model a…