may u r confused with java.... Abc a ; // this itself is creating an object of type ABC in C++ , no need to use new keyword to allocate m/m.
where as in C++ new keyword allocate m/m and return an address , so to make it work do. Abc *a=new ABC(); On Fri, Mar 9, 2012 at 8:28 PM, rahul sharma <[email protected]>wrote: > on left side of new there should be pointer that should collect the > address of the memory allocated.. > > write. > > ABC *a=new ABC(); > > > correct if wrng... > > > On Fri, Mar 9, 2012 at 8:19 PM, sanjiv yadav <[email protected]>wrote: > >> write.. >> >> Abc a=Abc() >> >> it will execute... >> >> >> On Fri, Mar 9, 2012 at 8:15 PM, ~*~VICKY~*~ <[email protected]>wrote: >> >>> #include<iostream> >>> using namespace std; >>> class Abc >>> { >>> >>> public : >>> int i; >>> Abc(){ i = 0;} >>> >>> }; >>> int main() >>> { Abc a = new Abc(); >>> cout<<a.i; >>> } >>> >>> >>> -- >>> Cheers, >>> >>> Vicky >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Regards.... >> >> Sanjiv Yadav >> >> MobNo.- 8050142693 >> >> Email Id- [email protected] >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
