G
Guest
Hi All
Check the following code
ClassOne{object objOne;}
ClassTwo{object objTwo;
ClassOne objClassOne;
Now i wud like the know the best way to assign memory to the objClassOne member
1. Assign it in the constructor: Pros: No error if u try to access it by mistake. Cons: Memory is assigned imm
2. Assign it outside like: ClassTwo objTwo; objTwo.objClassOne = new ClassOne(); Pros: Memory is assigned only when it is required. Cons: error if u try to access it by mistake
Please help. Thanx in advance
Check the following code
ClassOne{object objOne;}
ClassTwo{object objTwo;
ClassOne objClassOne;
Now i wud like the know the best way to assign memory to the objClassOne member
1. Assign it in the constructor: Pros: No error if u try to access it by mistake. Cons: Memory is assigned imm
2. Assign it outside like: ClassTwo objTwo; objTwo.objClassOne = new ClassOne(); Pros: Memory is assigned only when it is required. Cons: error if u try to access it by mistake
Please help. Thanx in advance