I need a type that has both a place where int is stored and a place where bool is stored.
struct syntax is required at this time.
struct ib//type name { int n;//content bool b;};
This type is called structure and is created with the struct keyword
Grammar:
struct struct Name { Underlying data type variable name; }
Statement:
IB IB;
Assignment value:
ib={,true};
Call:
int na; BOOL = {1,true== ib.b;
Once again we are asking for a new request, and I need a type with built-in method (processor) with several properties (storage). May I?
In fact, +-*/is their processor for the underlying numeric type.
For a custom type, this type, called a class, is also called an object.
Create classes with the Class keyword.
class a //declaration section { int A; int Add (intint m); } int A::add (int n,int m) //completion of the declared method body { return n+m;}
In general, we need to initialize the properties of class, and to release a related resource from memory in case a is not allowed.
So a class has the following format
classA//Declarations Section{A (); //initialization function~a ();//destroying functions intA; intAddintNintm); }intA::add (intNintM//complete the declared method body{ returnn+m;} A::a () {A=Ten;//Initialize Properties}a::~A () {//There is no need to release the content}
Statement:
A MA;
Call:
int N; int a,b,c;a=ten; b== ma.a; // Call Property C = Ma.add (A, b); // Calling Methods
C + + syntax fourth custom type