Last couple of day I had been thinking of doing some hands on C++. So I have my VS 2008 editor and I leaverage the facilities out of it and started my C++ coding ( After many a years ... possibly after graduation days !!!)
I created a new Project from File->New ->Project -> CLR Console Application then I gave a name "VCApp".
In the project solution I can see that "VCApp.cpp" is the file where I can add my code/any custom written class.
When I have added a custom class named "A". Following is my code for my custom class,
public class A
{
public:
A()
{
Console::WriteLine("Inside A constructor.");
}
}
Though above is a very simple code snippet I was surprised to see following compile time errors
---------------------------------------------------------------------------------------
error C2628: 'A' followed by 'int' is illegal (did you forget a ';'?)
error C3874: return type of 'main' should be 'int' instead of 'A'
error C2664: 'A::A(const A &)' : cannot convert parameter 1 from 'int' to 'const A &'
---------------------------------------------------------------------------------------
I just did a quick inspection in my code then then found that code needs the scope termination operator ";" in proper places. So I modified as following ,
public class A{
public:
A()
{
Console::WriteLine("Inside A constructor.");
};
} ;
Just added a semicolon (1) while closing at end of constructor and (2) End of class and I found the build was succeeded.
Monday, October 5, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment