本关有一个未完成的类Int
,该类含有一个成员变量,请为该成员变量编写存取函数。存取函数以Java
风格命名,具体请参考主函数中的代码。
一共包含2个文件,main.cpp
和Int.h
。 用户仅能修改Int.h
中的内容。 main.cpp
的内容如下:
#include "Int.h"
#include <iostream>
using namespace std;
int main(){
int x;
cin>>x;
Int a;
a.setValue(x);
cout<<a.getValue()<<endl;
return 0;
}
然后下边给了
#ifndef _INT_H_ //这是define guard
#define _INT_H_ //在C和C++中,头文件都应该有这玩意
class Int{
让填写代码