#include <iostream>

using namespace std;

/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

C++ classes and objects: a class is a simple combination of variables and methods. Classes in C++ use structs and classes. The only difference is that they have different default access permissions

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /

Class Fruit{public: Fruit(){} class Fruit{public: Fruit(){} class Fruit{public: Fruit(){

/** class implementation function, 1. Can first declare and then implement (such as getName()), 2. Implement it directly in a class (such as setName()) **/ string getName(); Void setName(string n){//2. Implement name = n directly in the class; } private: string name; // name double weight; // Weight string color; // color int number; / / number}; // Notice the semicolon

String Fruit::getName(){// The first implementation of the class function, :: for scope, Fruit:: for return name in the Fruit class; }

int main()

{

string name;

Fruit fru; // Create the class object fru fru.setName(“banana”); // Class object fru call function name = fru.getName();

    cout << “name = ” << name << endl;

    return 0;

}