close
The difference between operator ".", "->" and "::".
#pragma once #include "stdafx.h" using namespace System; class CMethod1 { public: CMethod1() {} ~CMethod1() {} static double mul(int a, int b) { return a*b; } }; class CMethod2 { public: CMethod2() {} ~CMethod2() {} double mul(int a, int b) { return a*b; } }; int main(array<System::String ^> ^args) { //CMethod1 is static, dont need to new CMethod2 *ptr_method2 = new CMethod2(); CMethod2 obj_method2 = CMethod2(); //-------------------------------------- double dMul_static = CMethod1::mul( 3 , 2 ); // static double dMul_ptr = ptr_method2->mul( 3 , 2 ); // pointer double dMul_obj = obj_method2.mul( 3 , 2 ); // object //-------------------------------------- delete ptr_method2; //-------------------------------------- system("pause"); return 0; }
文章標籤
全站熱搜