#include <iostream>
class Foo
{
private:
int* ptr;
public:
Foo()
{
ptr = new int;
}
void print()
{
std::cout << "Hello World\n";
}
};
int main()
{
Foo* ptr{ nullptr };
ptr->print();
}
Why is print accessible ?
Print is not a static method, so it's not tied to the class but to the object. Is it because the compiler makes it inline or is it because print's body reside in the code section of the block so it's accessible throughout the program ?