class function help
Why wont this work
class hello
{
public:
void guy();
};
void hello::guy()
{
}
int main()
{
hello.guy()
return 0;
}
when i type hello. guy() verable wont be there
Because you did not create an object from the class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
class hello
{
public:
void guy();
};
void hello::guy()
{
}
int main()
{
// Create an object called "foo"
hello foo;
// Always call from the object
foo.guy()
return 0;
}
|
Because you did not create an object from the class
Try this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
class hello
{
public:
void guy();
};
void hello::guy()
{
}
int main()
{
// Create an object called "foo"
hello foo;
// Always call from the object
foo.guy();
return 0;
}
|
Topic archived. No new replies allowed.