J
Jess
Hello,
How can I create a constant object? I tried the following code but
failed:
#include<string>
using namespace std;
struct A{
int x;
string s;
};
int main(){
const A b;
b.x = 2;
b.s = "bs";
return 0;
}
In addition, how can I define a class/struct that has a const member
data? I tried the following but it also failed.
using namespace std;
struct A{
const int x;
string s;
};
Thanks.
How can I create a constant object? I tried the following code but
failed:
#include<string>
using namespace std;
struct A{
int x;
string s;
};
int main(){
const A b;
b.x = 2;
b.s = "bs";
return 0;
}
In addition, how can I define a class/struct that has a const member
data? I tried the following but it also failed.
using namespace std;
struct A{
const int x;
string s;
};
Thanks.