static example

#include<iostream>

class testStatic{
	static int a,b;
	int c;	
	public:
		testStatic( int _c):c(_c){		
	}
		static void output(testStatic & ts);
		int get();
};
int testStatic::a = 10;
int testStatic::b = 20;
void testStatic::output(testStatic & ts){
//	std::cout<< a << " " << b << std::endl;
//	std::cout<< c << "\n";
	std::cout<< ts.get() << std::endl;
}
int testStatic::get(){
	return c;
}
int main() {
	testStatic ts(30);
	testStatic::output(ts);
}


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326322350&siteId=291194637