.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> OOPS >> Post New QuestionBookmark and Share Subscribe to Forum

creation of object

Posted By: siba     Posted Date: March 25, 2010    Points:2   Category :OOPS
class a
{
int a1;
public:
a()
{
a1=9;
}
void show()
{
cout<<a1;
}
};
void main()
{
a oa();
oa.show();
}
it will show's an error such as
structure required on feft side of.or.*in function main()

Responses
Author: pooja             
Posted Date: March 25, 2010     Points: 5   

hi siba...



error is in main function ...


u must create object in the following way...

void main()
{

a aObj;

aObj.show();

}


hope this helps u....


please rate my response


Author: Lalij Mer             
Posted Date: March 26, 2010     Points: 5   

check this link
http://www.experts-exchange.com/Programming/Editors_IDEs/C_CPP_CS/CPP_Builder/Q_20978192.html

Please Check my answer if you help....
Thank You...

Lalit.
Author: Nabin             
Posted Date: March 26, 2010     Points: 5   

siba

I think the answer from pooja is correct

Thanks & Regards
Nabin

Author: siba             
Posted Date: March 26, 2010     Points: 5   

in this problem normally an object can create,but in the above procedure is can't create object?

Author: Dilip             
Posted Date: March 29, 2010     Points: 5   

Hi Siba,

Please clarify, Are you trying to write a C# code or C++ code?

If it C++ code then, the way you have mentioned to create an object is correct. No new keyword is required to create the object.I dont think you can put a() constuctor in public, because it is defaultly static it should outside be public.

Try that it will work.

Regards
Dilip

Regards
Dilip


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend