Calling Member Functions within Main C++

前端 未结 7 1508
野的像风
野的像风 2021-02-04 12:24
#include 

using namespace std;

class MyClass
{
public:
       void printInformation();
};

void MyClass::printInformation()
{
     return;
}

int main(         


        
7条回答
  •  执笔经年
    2021-02-04 12:51

    You need to create an object since printInformation() is non-static. Try:

    int main() {
    
    MyClass o;
    o.printInformation();
    
    fgetc( stdin );
    return(0);
    
    }
    

提交回复
热议问题