我有这 3 个代码文件,我想从构造函数中打印“刚刚创建的山”。你能告诉我我错在哪里以及我必须做什么吗?
山脉.h
#ifndef MOUNTAINS_H
#define MOUNTAINS_H
class Mountains{
public:
Mountains();
~Mountains();
};
#endif
山脉.cpp
#include <cstdlib>
#include <iostream>
#include "Mountains.h"
Mountains::Mountains()
{
cout<<"Mountains were just created"<<endl;
}
Mountains::~Mountains()
{
cout<<"Mountains are about to be destroyed"<<endl;
}
主文件
#include <cstdlib>
#include <iostream>
#include "Mountains.h"
int main(int argc, char *argv[])
{
Mountains m();
system("PAUSE");
return EXIT_SUCCESS;
}
我希望当我调用“Mountains m();
这没有发生”时将“刚刚创建的山”写入控制台。