initializing constructors argument in main
Feb 18, 2013 at 11:29pm
How can I add an argument to a constructor in the int main section?
I have
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
class slug_imf
{
public:
slug_imf(string);
};
slug_imf::slug_imf(string k)
{
cout << k << endl;
}
int main()
{
string n="hello";
slug_imf imf(n);
}
|
i want it to output :
hello
to the screen
Feb 18, 2013 at 11:38pm
What is not working with your example?
Assuming you have string etc included it should work just as you want it to.
Feb 18, 2013 at 11:52pm
I tried it again and you're right it works. Thanks. I must of not included something before.
Topic archived. No new replies allowed.