Can you create a Class object within an if statement?<br>
I need to be able to create a specific type of object depending <br>
on input from the user. I am trying to use the following code <br>
but I get an invalid declaration error. Any suggestions for a different <br>
approach would be greatly appreciated. I am tearing my hair out.<br>
If you need to know any details just drop me an email at <br>
<A HREF="mailtoetersen@cdsnet.net">petersen@cdsnet.net</A>.<br>
<br>
if (type == 1)<br>
Account NewAcct = new Account(pw,owner,acc,sb);<br>
<br>
else if (type == 2)<br>
JrAccount NewAcctJr = new JrAccount(pw, owner, acc, sb, bday);<br>
<br>
<br>
Thanks for any help <br>
Aleena
I need to be able to create a specific type of object depending <br>
on input from the user. I am trying to use the following code <br>
but I get an invalid declaration error. Any suggestions for a different <br>
approach would be greatly appreciated. I am tearing my hair out.<br>
If you need to know any details just drop me an email at <br>
<A HREF="mailtoetersen@cdsnet.net">petersen@cdsnet.net</A>.<br>
<br>
if (type == 1)<br>
Account NewAcct = new Account(pw,owner,acc,sb);<br>
<br>
else if (type == 2)<br>
JrAccount NewAcctJr = new JrAccount(pw, owner, acc, sb, bday);<br>
<br>
<br>
Thanks for any help <br>
Aleena