1051107547-q1.txt

来自「c++ progamming example」· 文本 代码 · 共 33 行

TXT
33
字号
//Muhammad 'Ifwan B. Md Jalal
//1051107547
//tutorial4b

#include <iostream>
using namespace std;

//create class with constructur
class CInt {			
public:
	CInt() {num = 0;};	//declare default constructur
	CInt(int c) {num = c;}; //daclare parameterized constructur
	void addCInt(CInt c1, CInt c2);				//initialized member function of addCint
	void displayNumber() {cout << endl << num << endl;};    //initialized member function of display number

private:
	int num;		//declare integer variable

};

void CInt::addCInt(CInt c1, CInt c2)  //declare function addCint
{
	num = c1.num + c2.num;	
};


void main() 			 //main function
{
	CInt i1(2), i2(4), i3;
	i3.addCInt(i1,i2);	//call the function
	i3.displayNumber();	//call the function

};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?