Why doesnt the main method work inside a class?
Jul 18, 2015 at 10:37am UTC
I'm new to c++,so i quite don't understand why the main method doesn't work inside the class.Will be grateful to the person who understands my problem and gives a solution to it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
// Example program
#include <iostream>
using namespace std;
class exc{
int main()
{
string name;
bool a=true ;
string ju="ad" ;
cout << "What is your name? " ;
cin>>name;
if (ju==name)
{
cout << "\nHello, " << name << "!\n" ;
}
else
{ cout<<"not acceptable" ;
}
}
};
Jul 18, 2015 at 10:59am UTC
main is the entry point into your program, it should not go in a class.
I suggest you work through the tutorials on this site.
Topic archived. No new replies allowed.