Thursday, 5 September 2013

Can I use my instance variable as the contructor parameter?

Can I use my instance variable as the contructor parameter?

class Myclass{
int x;
Myclass (int i){
x = i;
}
}
That is the code I have in my book. I wanted to know if this code would work?
class Myclass{
int x;
Myclass (x)
}
I also could try
class Myclass{
int x;
Myclass (int x)
}
in response to my first answer...would this work?

No comments:

Post a Comment