J
John
Hi all:
In my code I define a class with inline constructor. But it does not
work. I describe the class as below:
myclass{
public:
myclass(int a, int b) { r1 = a; r2 = b;}
protected:
int r1;
int r2;
double z;
}
But the constructor does not work. When I declare an object of the
class, the constructor can not correctly initialize the variables.
Then I modify the code as below:
myclass{
public:
myclass(int a, int b);
protected:
int r1;
int r2;
double z;
}
myclass::myclass(int a, int b) {
r1 = a;
r2 = b;
}
It works. When I declare an object of the class, the constructor can
correctly initialize variables.
What is the problem?
Thanks a lot.
John
In my code I define a class with inline constructor. But it does not
work. I describe the class as below:
myclass{
public:
myclass(int a, int b) { r1 = a; r2 = b;}
protected:
int r1;
int r2;
double z;
}
But the constructor does not work. When I declare an object of the
class, the constructor can not correctly initialize the variables.
Then I modify the code as below:
myclass{
public:
myclass(int a, int b);
protected:
int r1;
int r2;
double z;
}
myclass::myclass(int a, int b) {
r1 = a;
r2 = b;
}
It works. When I declare an object of the class, the constructor can
correctly initialize variables.
What is the problem?
Thanks a lot.
John