The code is as follows:
file contains and preprocessing. CPP: The entry point that defines the console application. #include "stdafx.h" #include <string> #include <stdio.h> #include <windows.h> #include <iostream >using namespace Std;class fruit{public:fruit (const string Nst,const string cst): Name (NST), colour (CST) {}void print ( {cout << name << endl;cout << colour << Endl;} void Ck (int i) {for (; i <; i++) {printf ("%d", I);}} Private:string name;const string colour;}; int _tmain (int argc, _tchar* argv[]) {Fruit Apple = fruit ("A", "1"); Fruit orange = fruit ("B", "2"); Apple.print (); orange.pri NT (); Fruit a=a;a.ck (6); GetChar (); return 0;}
Public function in the class member, here I declare a CK function name
A For loop is nested inside, and when called, the class initialization object calls the CK
It is not possible to call directly through the class name, which differs from C in that it initializes an object to invoke.
Fruit a=a; This piece of online has many kinds of explanations, finally see the disassembly is not a hint, anyway can call out on the line.
Leave a picture. :
Class member invocation in "record" C + +