Skip to content

Latest commit

 

History

History
65 lines (45 loc) · 2.89 KB

classes-and-structs-cpp.md

File metadata and controls

65 lines (45 loc) · 2.89 KB
Error in user YAML: (<unknown>): did not find expected ',' or ']' while parsing a flow sequence at line 10 column 22
---
title: "Classes and Structs (C++) | Microsoft Docs"
ms.custom: ""
ms.date: "11/04/2016"
ms.reviewer: ""
ms.suite: ""
ms.technology: ["cpp-language"]
ms.tgt_pltfrm: ""
ms.topic: "language-reference"
dev_langs: ["C++"]
helpviewer_keywords: ["[""Visual C++, classes"", ""structures, C++ classes"", ""user-defined types [C++]"", ""classes [C++]"", ""user-defined types, C++ classes""]"]
ms.assetid: 516dd496-13fb-4f17-845a-e9ca45437873
caps.latest.revision: 9
author: "mikeblome"
ms.author: "mblome"
manager: "ghogen"
translation.priority.ht: ["cs-cz", "de-de", "es-es", "fr-fr", "it-it", "ja-jp", "ko-kr", "pl-pl", "pt-br", "ru-ru", "tr-tr", "zh-cn", "zh-tw"]
---

Classes and Structs (C++)

This section introduces C++ classes and structs. The two constructs are identical in C++ except that in structs the default accessibility is public, whereas in classes the default is private.

Classes and structs are the constructs whereby you define your own types. Classes and structs can both contain data members and member functions, which enable you to describe the type's state and behavior.

The following topics are included:

The three class types are structure, class, and union. They are declared using the struct, class, and union keywords (see Defining Class Types). The following table shows the differences among the three class types.

For more information on unions, see Unions. For information on managed classes and structs, see Classes and Structs.

Access Control and Constraints of Structures, Classes and Unions

Structures Classes Unions
class key is struct class key is class class key is union
Default access is public Default access is private Default access is public
No usage constraints No usage constraints Use only one member at a time

See Also

C++ Language Reference