Regarding my understanding of this question:
Question # 03:
Take any class from your course project. "Each member should have different class from their project".
Make one of its int data member constant.
Create 4 functions to see the use of Constant keyword. Each function should return the modified integer (not void).
Function Name Data to be modified Function Type Int NonConstant( int x) Non-Constant Non-Constant Int ConstantData( int x) Constant Non-Constant Int NonFunction( int x) Non-Constant Constant Int ConstantBoth( int x) Constant Constant
I'm not asking anyone to do this for me, I just want to understand what the question is really trying to say, as I'm getting so many errors in my code if I try to apply changes as shown in the figure.
#include<iostream>
using namespace std;
class Project
{
private:
int const x;
int y;
public:
Project():x(5){}
int NonConstant(int const x){
this->y=x;
return y;
}
int ConstData(const int x)
return x;
}
//
// const int ConstFunction(int x){
// x++;
// return x;
// }
// const void ConstBoth(void) const {
// x++;
// }
};
int main()
{
Project obj;
cout<<"NonConstant(1): "<<obj.NonConstant(1)<<endl;
cout<<"ConstData(1): "<<obj.ConstData(1)<<endl;
cout<<"ConstFunction(1): "<<obj.ConstFunction(1)<<endl;
// obj.ConstBoth();
}